我想迭代一個CSV文件,並檢查位置行[1]是否是某些國家。如果是,則應該跳到下一行。迭代CSV文件並跳過一圈?
但此刻它是我的,如果病情未能由於:
$countries = array("Österreich", "Schweiz", "Niederlande", "Großbritannien", "United States");
while (($row = fgetcsv($inputFile, 0, $delimiter)) !== false) {
foreach ($countries as $country){
if(((stripos($row[1], $country === false))) && stripos($row[0], "Card")){
echo $row[0] . "\t => \t" . $row[1] . "\n";
}
}
... some other code (Dealing with the values) ...
}
要繼續編碼我檢查,如果我的說法是對的,如果我得到所需的值。但我不。
我只想獲得國家不是數組中的國家之一的值,如果row[1]
中的標題包含card
這個詞。但如果我使用這個條件,我沒有得到任何價值。 但是,怎麼了?
這是一個CSV樣本:
products_name;products_edition
"PlayStation Network Card 20€";"Deutschland ";
"PlayStation Network Card 50€";Österreich;
"Playstation Plus Live Card - 365 Tage";Deutschland;
"PlayStation Network Card 10£ ";Großbritannien;
"PlayStation Network Card 20$";"United States";
所以實際我應該得到"PlayStation Network Card 20€";"Deutschland ";
和"Playstation Plus Live Card - 365 Tage";Deutschland;
。但我不...
有人知道爲什麼,如果是的話我該如何解決?
我的第二個問題是: 如果products_edition
一個值與一個國家從我的陣列,實際而圈應該得到跳過,因爲我不想處理的產品,如果它是來自這些國家的匹配。但是,我怎麼能說出這一段時間呢?
我不想停止這個洞while while循環,只有一圈,其中row[1]
匹配我國的陣列國家之一。
有沒有人有想法? 問候,謝謝!
編輯: 我現在知道如何跳過實際循環圈並告訴循環繼續下一圈。我只是用continue;
。但還有我的其他條件問題...:/
非常感謝! – Jan