Some small problem with strings, arrays and foreach
<?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
精彩评论