PHP - Return Multidimensional Array Through Foreach

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

Answers


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>';


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


Need Your Help

Websocket not working: unexpected responce code 404

java java-ee websocket

I am trying to create javaee application with websockets however can't get the program to work properly. Using Tomcat 7, Java EE 7 application with websockets.

logalyze how to add event defination

events

I am working on logalyze, there is very limited documentation for this tool.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.