lundi 9 février 2015

Check for existing values with if in foreach?

I have array with already existing values:



$existingValues = array();


now i get new values in xml file (is a import script) but i have to avoid insert of already existing values, my question is, how can i do a if check in foreach where i list all new values from xml?



$i = 1;

foreach($node->children() as $child) :
$attribute2 = $child->attributes();
$productcode = $attribute2['sku'];
$productvariant = $attribute2['variantid'];
$productprice = $attribute2['price'];

if ($attribute2['sku']) :
echo $productcode . ' - ' . $productvariant . '<br>';
endif;

$i++;
endforeach;


I tried with in_array() but it's not correct.


Aucun commentaire:

Enregistrer un commentaire