开发者

Some small problem with strings, arrays and foreach

开发者 https://www.devze.com 2023-03-26 08:46 出处:网络
<?php $ep_place = \'Arugghh!\'; $eps_array = array(); $eps_array[] = $ep_place; foreach($eps_array[1] as $eps_match开发者_C百科)
<?php


$ep_place = 'Arugghh!';    

$eps_array = array();

$eps_array[] = $ep_place;

foreach($eps_array[1] as $eps_match开发者_C百科)
{ 

$argh = $eps_match;

echo $argh;
}

?>

Warning: Invalid argument supplied for foreach()

What is it that I doing wrong here..?! I appreciate any help!


You are looping over the second element of $eps_array, which is wrong.

Change your foreach to:

foreach($eps_array as $eps_match) { }



$ep_place = 'Arugghh!';    

$eps_array = array();

$eps_array[] = $ep_place;

foreach($eps_array as $eps_match)
{ 

$argh = $eps_match;

echo $argh;
}

You should use array in foreach but not element of array

0

精彩评论

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