Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在CSV文件上迭代并跳过?_Php_Arrays_Csv_If Statement_Boolean Logic - Fatal编程技术网

Php 在CSV文件上迭代并跳过?

Php 在CSV文件上迭代并跳过?,php,arrays,csv,if-statement,boolean-logic,Php,Arrays,Csv,If Statement,Boolean Logic,我想迭代一个CSV文件,并检查位置行[1]上是否有某些国家。如果是,则应将while圈跳到下一行 但目前由于我的if条件,它失败了: $countries = array("Österreich", "Schweiz", "Niederlande", "Großbritannien", "United States"); while (($row = fgetcsv($inputFile, 0, $delimiter)) !== false) { foreach ($count

我想迭代一个CSV文件,并检查位置行[1]上是否有某些国家。如果是,则应将while圈跳到下一行

但目前由于我的if条件,它失败了:

$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) ...     
}
为了继续编码,我检查了我的语句是否正确,是否得到了所需的值。但我没有

我只想获取国家/地区不是数组中国家/地区之一的值,如果
行[1]
中的标题包含单词
。但是如果我使用这个if条件,我得不到任何值。 但有什么不对呢

这是一个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网卡20欧元”;“德国”
“Playstation Plus实时卡-365”;德国。但我不

有人知道为什么吗?如果有,我如何解决

我的第二个问题是: 如果
products\u edition
的一个值与我数组中的一个国家匹配,则应跳过实际的while lap,因为如果产品来自这些国家,我不想处理该产品。但我怎么才能知道那是一圈呢

我不想停止while循环,只有while圈(其中
行[1]
与我的国家/地区数组中的一个国家/地区匹配)

有人有主意吗? 你好,谢谢

编辑: 我现在知道如何跳过实际的圈,并告诉圈继续下一圈。我只是使用
继续。但还有我的另一个if条件问题…:/

$countries = array("Österreich", "Schweiz", "Niederlande", "Großbritannien", "United States");
while (($row = fgetcsv($inputFile, 0, $delimiter)) !== false) {
    if (in_array($row[1], $countries) && strpos($row['1'], "Card") !== false) {
        continue;
    }
    echo $row[0] . "\t => \t" . $row[1] . "\n";
//... some other code (Dealing with the values) ...     
}