0
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!

3
  • can you try elaborate your problem further? xD Commented Aug 5, 2011 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 Commented Aug 5, 2011 at 17:27
  • Adding print_r($eps_array); below the preg_push produces: Array ( [0] => http://xxxxx.com/xxxx ) ... Commented Aug 5, 2011 at 17:37

4 Answers 4

1

try that

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

but whole code is just weird

Sign up to request clarification or add additional context in comments.

Comments

1

$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

1 Comment

That worked! I would not have been able to create that even if I read the whole manual. Thanks!
0

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

Comments

-1

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); 
}

2 Comments

aha, forgot to set eps_array[1] = array(); :)
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..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.