echo an array (banging head on table !)

HI php gurus!

I have the following array returned with print_r

[code]Array
(
[0] => Array
(
[active_users] => 127
[total_users] => 56681
[total_teams] => 12107
[ac_users] => 0
)

)[/code]

If this is what I have sitting therre waiting to be used how on earth do i “echo” this as :

active users : 127
total users : 56681
etc…

been trying this without success for three hours, need a breakthrough before i go mad !

thanks in advance , all suggestions highly appreciated !

Let say your array name is $arr, then your code would be:
[php]echo ‘active users: ‘.$arr[0][‘active_users’].’
’;
echo ‘total users: ‘.$arr[0][‘total_users’].’
’;[/php]
etc.

That’s a multidimensional array, you should read more on arrays.

Multiple ways to do this. If you want to loop you’d use:
[php]foreach($example as $array){
echo $array[‘active_users’];
}[/php]

Two out put the array another way without looping you simply:
[php]echo $example[0][“active_users”];[/php]

Phphelp beat me by 5 seconds haha.
:slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service