Php数组读数

时间:2016-11-25 17:38:44

标签: php arrays foreach

我的代码有问题我想读这样的数组,

    Array
(
    [0] => Array
        (
            [Id] => 0
            [Name] => 'Da Siick f0rest ;'
            [Frags] => 2
            [Time] => 2616
            [TimeF] => 43:36
        )

    [1] => Array
        (
            [Id] => 0
            [Name] => ReTrY
            [Frags] => 0
            [Time] => 7004
            [TimeF] => 01:56:44
        )

    [2] => Array
        (
            [Id] => 0
            [Name] => huFFle.
            [Frags] => 0
            [Time] => 434
            [TimeF] => 07:14
        )
)

我尝试使用这样的代码来读取数组,但是不起作用。我试图回显字符串$ player_nickname,但它没有显示结果。

    <?php $players = file_get_contents('http://gametracker.al/../../Example.php?ip='.$server_ip.'&port='.$server_port.'');


        foreach ($players as $Player) {

            $player_nickname        = mysql_real_escape_string($Player['Name']);

            $player_score           = mysql_real_escape_string($Player['Frags']);

            $player_time            = mysql_real_escape_string($Player['TimeF']);

            $player_nickname        = (!empty($player_nickname)) ? $player_nickname : 'anonymous';

echo $player_nickname;

        } ?>

谢谢大家。

1 个答案:

答案 0 :(得分:0)

mysql_real_escape_string已弃用,已在PHP7上删除。您是否通过在开发环境中编辑php.ini来启用显示错误消息?