Reputation: 987
I'm trying to return a value from a multidimensional array, but it doesn't seem to be working.
Array -
[players] => Array
(
[0] => Array
(
[player] => Necro
[score] => 0
[deaths] => 0
[gq_name] =>
[gq_kills] =>
[gq_deaths] => 0
[gq_score] => 0
[gq_ping] =>
)
)
PHP Foreach
<?php
$dayzplayers = $results["dayz"]["players"];
foreach($dayzplayers as $k => $v) {
echo ' <b>'.$v["player"].'</b>';
} ?>
Upvotes: 1
Views: 361
Reputation: 4842
The ['player'] index appears to have an invisible control character in the key SOH (Start of Heading)
Try echo ' <b>'.$v[chr(1) . "player"].'</b>';
instead of echo ' <b>'.$v["player"].'</b>';
Upvotes: 1
Reputation: 2511
If the data is what you posted in the first listing, this should work:
foreach($dayzplayers as $player) {
echo $player[chr(1).'player'];
}
as per http://codepad.org/kUYueGVh
Upvotes: 0