Esempio n. 1
0
     $contents = mb_convert_encoding($contents, 'UTF-8');
 }
 // break out each line of the file
 $rows = str_getcsv($contents, PHP_EOL);
 $cards = [];
 // iterate over the rows and submit the cards
 foreach ($rows as $row) {
     // parse out the card values
     $card = str_getcsv($row, ',');
     $name = $card[0];
     $set = $card[1];
     $quantity = $card[2];
     $price = $card[3];
     $date = $card[4];
     // get the multiverse ID
     $mid = $echo->cardReference($name, $set);
     // if we're good, add the card or build the print to screen
     if ($mid) {
         if (!$ids_only) {
             $response = $echo->addCard($mid, $quantity, $price, $date);
             if (!$response) {
                 $errors['adds'] = [$mid, $name, $set, $quantity, $price, $date];
             } else {
                 $success[] = [$mid, $name, $set, $quantity, $price, $date];
             }
         } else {
             $csv[] = [$mid, $name, $set, $quantity, $price, $date];
         }
     } else {
         $errors['mids'] = $card;
     }