I want to iterate over a CSV file and check if on position row[1] are certain countries. If yes, the while lap should be skipped to the next row.
But at the moment it is failing due to my if condition:
$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] . "
";
}
}
... some other code (Dealing with the values) ...
}
To continue coding I was checking if my statement is right and if I get the desired values. But I do not.
I want only to get the values where the country is not one of the countries in the array and if the title in row[1]
contains the word card
. But if I use this if condition I get no values.
But what is wrong?
This is a CSV sample:
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";
So actual I should get "PlayStation Network Card 20€";"Deutschland ";
and "Playstation Plus Live Card - 365 Tage";Deutschland;
. But I do not...
Does anybody know why and if yes how can I fix that?
And my second question is:
If one value of products_edition
is matching with one country from my array, the actual while lap should get skipped because I do not want to handle the product if it is from those countries. But how can I tell that that actual while lap?
I do not want to stop the hole while loop, only the while lap where row[1]
is matching one of the countries in my country array.
Does anybody has an idea? Greetings and Thank You!
EDIT:
I know now how to skip the actual loop lap and to tell the loop to continue with the next lap. I just use continue;
. But there is still my other if condition problem... :/