if ($_POST['op_ep_cat'] == 'op_single_ep') 
{
$ep_place = $_POST['the_place']; 
$eps_array = array();   
    array_push($eps_array, $ep_place); 
}

else if ($_POST['op_ep_cat'] == 'op_category') {
    $cat_site = $_POST['the_place'];    
    $taken_cat_site = file_get_contents($cat_site);

    if (preg_match_all('#<div class="content_ep"><a href="(.+?)"#si', $taken_cat_site, $eps_array));

    else if (preg_match_all('#<div class="postlist">\s*<a href="(.+?)"#si', $taken_cat_site, $eps_array));

}


foreach(array_reverse($eps_array[1]) as $eps_match)
{ 
     echo 'Arughh!';
}

The above works for the 'op_category' perfectly, but not for the 'op_single_ep'... So basically $ep_place needs to be apart of the $eps_array[1], if possible, somehow.. Hopefully any of this makes sense!

I appreciate any help!

link|improve this question

80% accept rate
can you try elaborate your problem further? xD – kapitanluffy Aug 5 '11 at 17:26
You havent provided what exactly isn't working. do a print_r of your $_POST and $eps_array to see the problem – mrBorna Aug 5 '11 at 17:27
Adding print_r($eps_array); below the preg_push produces: Array ( [0] => http://xxxxx.com/xxxx ) ... – Suffice Aug 5 '11 at 17:37
feedback

4 Answers

up vote 1 down vote accepted

try that

$eps_array = array(1 => array($_POST['the_place']));

but whole code is just weird

link|improve this answer
That simplified everything, thanks! – Suffice Aug 5 '11 at 17:48
feedback

$eps_array[1] is not array, is element of $eps_array
You can make array

$eps_array = array(1=>array());
array_push($eps_array[1], $ep_place); 

Try to read manual about What is array

link|improve this answer
That worked! I would not have been able to create that even if I read the whole manual. Thanks! – Suffice Aug 5 '11 at 17:41
feedback

it'd be $eps_array[0] for the op_single_ep version. Remember, PHP arrays have 0-based indexes.

link|improve this answer
feedback

Try this

if ($_POST['op_ep_cat'] == 'op_single_ep') 
{
  $ep_place = $_POST['the_place'];  
  $eps_array = array();
  $eps_array[1] = array();
  array_push($eps_array[1], $ep_place); 
}
link|improve this answer
1  
aha, forgot to set eps_array[1] = array(); :) – ace Aug 5 '11 at 17:26
Tried that, and got: array_push() [function.array-push]: First argument should be an array, array_reverse() [function.array-reverse]: The argument should be an array, Invalid argument supplied for foreach()... Oh, hmm.. – Suffice Aug 5 '11 at 17:29
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.