foreach problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

foreach problem

Post by itsmani1 »

i am having problem with foreach loop. can anyone help me how can fetch items form this array using foreach.

Code: Select all

Array
(
    [0] => Array
        (
            [0] => Array
                (
                    [EVENTNAME] => New York Islanders
                    [CATEGORYID] => 94
                )
            [1] => Array
                (
                    [EVENTNAME] => New Jersey Devils
                    [CATEGORYID] => 94
                )
        )

    [1] => Array
        (
            [0] => Array
                (
                    [EVENTNAME] => Boston Bruins
                    [CATEGORYID] => 95
                )
	)
)
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

Post by kaszu »

You should look at http://uk.php.net/foreach

Code: Select all

foreach($myarray as $group)
{
  foreach($group as $item)
  {
      echo 'Event: '.$item['EVENTNAME'].' CategoryID: '.$item['CATEGORYID'].'<br />';
  }
}
Post Reply