FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » illegal offset problem
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: illegal offset problem [message #184052 is a reply to message #184050] Tue, 03 December 2013 23:06 Go to previous messageGo to previous message
Ben Bacarisse is currently offline  Ben Bacarisse
Messages: 82
Registered: November 2013
Karma:
Member
richard <noreply(at)example(dot)com> writes:
<snip>
> foreach ($six0 as $itemkey => $item) {
> $song=$six0[$itemkey]['track'];
> echo "<div>$song</div>";};
>
> works fine. shows all songs for every year.
>
> }

This code is odd because it gets the array element and the index. The
body of the loop then indexes the array. Why not either only get the
index or, better, only get the element?

> foreach ($six0 as $itemkey => $item) {
> $song=$six0[$itemkey]['track'];
> if ($year==$show){ echo "<div>$song</div>";}
> }
>
> Show nothing. Why?

This code is even odder because neither $year nor $show change in the
loop. It will either do the same as the first loop and print every song
for every year, or it will print nothing at all.

I suspect that $year is a typo. Maybe it should be something like
$item['year']?

--
Ben.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Can I download file with address like this "http://***.com/file.php/ABC.html" automatically ?
Next Topic: request for error checking feature
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Sep 28 23:14:11 GMT 2024

Total time taken to generate the page: 0.04223 seconds