I have the following multidimensional array.
I have run a foreach loop and am trying to echo the client nicknames of the 2 users. The code I am running is as follows.
$client_r = $Ts3->clientList();
foreach ($client_r as $client)
{
echo $client['data']['client_nickname'];
}
What am I doing wrong?
Try this:
foreach ($client_r as $client)
{
echo $client['data'][0]['client_nickname'];
echo $client['data'][1]['client_nickname'];
// As there are further arrays inside array, so you have to include the index also
}
If you start from the data
then your access will be easy-
In data you have again array, so the $client
now stores the sub array, now you can easily access your client_nickname
.
$client_r = $Ts3->clientList();
foreach ($client_r['data'] as $client){
echo $client['client_nickname'];
}
This may be solve your problem.