I wrote a script to check a remote xml file for the stock state of some products.
I want to list all sizes ID having "available"=true and "appearance id"=2
the expected result should be
2
3
4
5
6
but i'm getting
38
2
3
4
5
6
where the hell does this "38" comes from ?
Here's the script:
<?php $checkstockcolor = "2"; $apiurl = "http://api.spreadshirt.com/api/v1/shops/266497/productTypes/175"; $feed = simplexml_load_file($apiurl); $producttype = $feed->productType; $stockstate = $feed->stockStates->stockState; foreach ($stockstate as $stock) { $available = $stock->available; $stockcolor = $stock->appearance[id]; $size = $stock->size[id]; // garder uniquement les résultats de la couleur présentement sélectionnée if ($stockcolor == $checkstockcolor && $available == "true") { echo "$size<br>"; } } ?>
Thank you !