Forum Moderators: coopster

Message Too Old, No Replies

fetching data from an array

         

ahmed24

10:43 pm on Jul 15, 2009 (gmt 0)

10+ Year Member



i need some help with getting values from an array. i have a variable called $courses that is an array and when i echo it like this:

print_r($courses);

i get the result something like this:

Array
(

[1] => Array
(
[FIRST_NAME] => Bob
[LAST_NAME] => Smith
)

[2] => Array
(
[FIRST_NAME] => John
[LAST_NAME] => Townsend
)

)

there is only 2 sets of data in the sample output above but sometimes there is more. so i'm wondering how i can take each value from each array and loop it?

thanks in advance for any help

mooger35

11:02 pm on Jul 15, 2009 (gmt 0)

10+ Year Member



not sure how you want to dispay it but hopefully this will help...

foreach($courses as $key => $val){
echo $courses[$key]['FIRST_NAME']." ".$courses[$key]['LAST_NAME']."<br />\r\n";
}

eelixduppy

2:49 am on Jul 16, 2009 (gmt 0)



This link might also be of help: [php.net...]