I have an array that I can’t seem to get my data back out of. What I would like is for each name (test1…) to have multiple urls associated with them. If you look at the last test (test5), there are 2 urls but this foreach loop only gives me one. Why?
Here is the array structure and my foreach loop.
Array
(
[test1] => Array
(
[0] => http://www....
)
[test2] => Array
(
[0] => http://www....
)
[test3] => Array
(
[0] => http://www....
)
[test4] => Array
(
[0] => http://www....
)
[test5] => Array
(
[0] => http://www.yahoo.com
[1] => http://www.google.com
)
)
foreach($source as $name=>$url)
{
foreach($url as $_url);
{
echo $name.' - ';
echo $_url.'<br>';
}
}
You have a semicolon after your second foreach:
foreach(...); {...which shouldn’t be there. The code below works as you would expect.