开发者

Arrays, foreach, adding string to array trouble

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_c开发者_运维百科at_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!


try that

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

but whole code is just weird


$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


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


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜