$defindexes = get_tf2_allitem_node($backpack,"defindex");
$itemmap = array();
foreach ($defindexes as $items)
{
$imageURL = find_tf2_allitem_node_by_defindex($schema,$items,"image_url");
$itemmap[$items] = $imageURL;
}
Essentially I’m trying to parse a schema document, and a backpack document in simpleXML. $defindexes gets all the indexes of items in the given $backpack object. I’m trying to then create a $itemmap of items in backpack => image_url of those items, which I’m polling using find_tf2_allitem_node_by_defindex() and supplying it with the $schema as an argument, and going over each index. I think something’s wrong with the way I’m passing $items to the function, because no values are returning. I’m guessing it has something to do with the fact that $defindexes is an array of objects?
What’s wrong with this?
Sample $defindexes dump :
array(146) {
[0]=> object(SimpleXMLElement)#10 (1) { [0]=> string(2) "42" }
[1]=> object(SimpleXMLElement)#8 (1) { [0]=> string(2) "44" }
[2]=> object(SimpleXMLElement)#11 (1) { [0]=> string(2) "37" }
[3]=> object(SimpleXMLElement)#12 (1) { [0]=> string(3) "116" }
...
}
I resolved this by modifying my $defindexes to contain an array of SimpleXML objects casted to strings. In this way the foreach loop was able to complete since the find_tf2_allitem_node_by_defindex() function would now receive a string to parse.