my problem is that i have array with some EANs and i need to match them with EANs from RSS. I need to create separated XML just with data what i want. But if i put IF in_array() function some of data is missing. Thanks for advice guys
$feed = simplexml_load_file('http://ift.tt/2g6K636','SimpleXMLElement', LIBXML_NOCDATA);
$pampersXML = new SimpleXMLElement('<xml/>');
$pampers = ["4015400264491","4015400507499","8001090172518","4015400736424","4015400737551","4015400737551"];
foreach($feed->SHOPITEM as $item){
if (in_array($item->EAN, $pampers)){
$product = $pampersXML->addChild('product');
$product->addChild('PRODUCTNAME', $item->PRODUCTNAME);
$product->addChild('URL', $item->URL);
$product->addChild('IMGURL', $item->IMGURL);
$product->addChild('PRICE_ORIG', $item->PRICE_ORIG);
$product->addChild('EAN', $item->EAN);
}
}
$pampersXML->asXML('feed/pampers-premium-care.xml');
Aucun commentaire:
Enregistrer un commentaire