0

How do I access data in an object array like this? In a foreach loop.

[name:SteamPlayer:private] => Pingu Gaige

Full array here: http://paste.laravel.com/Xic

I have:

foreach($players as $player){
    echo $player.. now I'm lost. 
}
Koraktor
  • 41,357
  • 10
  • 69
  • 99
Nicekiwi
  • 4,567
  • 11
  • 49
  • 88
  • The property is private, this means you can only access it from inside the class `SteamPlayer`. In that case `$this->name` is the name. – pNre Oct 08 '13 at 10:52

2 Answers2

0

this could work if not private:

foreach($players as $key => value){
    echo 'name : '. $key . ' and ' $value->connectTime . 
}
Developerium
  • 7,155
  • 5
  • 36
  • 56
0

You're referring to Steam Condenser's SteamPlayer class here. (Full code on GitHub)

foreach($players as $key => value){
    echo "{$value->getName()} has a score of {$value->getScore()}\n";
}
Koraktor
  • 41,357
  • 10
  • 69
  • 99