Je viens vous demander conseil. Voici mon code :
Code : Tout sélectionner
if ($monfichier = fopen($urlcsv, 'r')) {
$row = 1;
$ref = [];
// Get REF and QTY to the csv file, associate key value in array
while (($ligne = fgetcsv($monfichier, 1000, ";")) !== FALSE) {
if (!empty($ligne[2])) {
$ref[] = [$ligne[2] => intval($ligne[6])];
}
$row++;
}
// Delete first entrie
$refs = array_shift($ref);
$product_ref = [];
for ($i = 0; $i < count($ref); $i++) {
foreach ($db->query("SELECT reference, id_product FROM ps_product WHERE reference = '" . key($ref[$i]) . "' AND id_supplier = '2'") as $row) {
$product_ref[] = [$row["reference"] => $row["id_product"]];
}
if (in_array($product_ref[$i]["ref"], $ref)) {
var_dump($ref[$i]);
}
}
// $product_ref is an array who contain ref and id
// get values in array 1
// get values in array 2
// verify if the values in array 1 is in array 2
// add values in array 1 in array 2
$db = null;
fclose($monfichier);
/*$fichierecriture = fopen("fichier.csv", 'w');
fputs($fichierecriture, $newcontenu);
fclose($fichierecriture);*/
}Le tableau deux : ["ref" => 11651, "id_product" => 35002]
Mon souhait est de faire le tableau : ["ref" => 11651, "id_product" => 35002, "qty" => 4]
J'ai le nez dans le guidon, je ne suis pas objectif. Pouvez vous m'aider s'il vous plaît ?
(si besoin de plus d'informations, aucun soucis)