1

我试图从多维数组中返回一个值,但它似乎不起作用。

数组-

[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>';
              } ?>
4

2 回答 2

1

['player'] 索引在键 SOH(标题开始)中似乎有一个不可见的控制字符

尝试echo ' <b>'.$v[chr(1) . "player"].'</b>';代替echo ' <b>'.$v["player"].'</b>';

于 2013-01-23T13:52:09.537 回答
0

如果数据是您在第一个清单中发布的数据,则应该可以:

foreach($dayzplayers as $player) {
    echo $player[chr(1).'player'];
}

根据http://codepad.org/kUYueGVh

于 2013-01-23T13:48:44.310 回答