I'm working with a multi-dimensional PHP array that is converted from an XML file, and am struggling to grab specific attributes from all key names (I don't know the name of all keys, but they all have the same attributes.)
Each Key inside "$player_stats" is structured like this in the array:
[RandomKeyName] => SimpleXMLElement Object
(
[@attributes] => Array
(
[assists] => 0.10
[rebounds] => 8
[operator] => >
[overall] => 1.45
)
)
I'm trying to achieve something like below. Am I not able to grab attributes from keys when using $key => $value?
foreach ($player_stats as $key => $value) {
$rebounds = $key->rebounds;
$assists = $key->assists;
echo "$key has $rebounds Rebounds and $assists Assists. <br>";
}
$key works in this example but the attributes I tried grabbing don't. Any tips or pointers for grabbing specific attributes for all keys without knowing the key names would be great, thanks!
edit:
The part of the XML I'm trying to get key objects of:
<Player_Stats>
<RandomKeyName1 assists="0.04" rebounds="9" operator=">" overall="0.78" />
<RandomKeyName2 assists="0.04" rebounds="4" operator=">" overall="2.07" />
<RandomKeyName3 assists="0.04" rebounds="1" operator=">" overall="3.76" />
<RandomKeyName4 assists="0.04" rebounds="10" operator=">" overall="0.06" />
</Player_Stats>