The $value prints correctly. The number(s) are correct for $value so I think that part is eliminated.
If I manually enter the actual numbers in ($value)->price
like (10079)->price
, the function works fine and the last line print_r ($price)
prints the number it supposed to.
For some reason $value is not working in the context of $xml_price = $fetch_app->products($value)->price;
as the function returns nil for $price
foreach ($_SESSION['queueList'] as $value){
//this prints the correct item(s) in 'queueList'
print_r ($value);
//this gets the node with the price info
$xml_price = $fetch_app->products($value)->price;
//this converts the simpleXML node to a string
$price = ((string) $xml_price);
//session var accumulates the item prices in cart
$_SESSION['totalPrice'] += $price;
print_r ($price);
}
So why is the $value
variable not working, but an actual number does, even though I have printed the $value
and it shows the correct number? The number is a float by the way, not sure if that matters.