Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/239.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 正则表达式双引号和html标记_Php_Regex_Symfony - Fatal编程技术网

Php 正则表达式双引号和html标记

Php 正则表达式双引号和html标记,php,regex,symfony,Php,Regex,Symfony,我从csv文件中读取数据。并将其写入字符串,现在需要对这些数据进行分类 if (($handle = fopen($_FILES['app_bundle_upload_type']['tmp_name']['file'], "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num = count($data); $row++;

我从csv文件中读取数据。并将其写入字符串,现在需要对这些数据进行分类

  if (($handle = fopen($_FILES['app_bundle_upload_type']['tmp_name']['file'], "r")) !== FALSE) {
      while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
           $num = count($data);
           $row++;
           for ($c=0; $c < $num; $c++) {
               $result.= $data[$c] . "<br />\n";
           }
      }
 }
它逐行读取并以数组形式返回

$data[$i]

尝试以下操作:

<?php

    $string = '1;"admin_loginIncorrect";"Podane hasło jest nieprawidłowe";"1";"0" 2;"admin_logOut";"Wyloguj";"1";"0" 3786;"tutorial_text_3";"Wenn Sie ein Produkt kaufen möchten dessen Preis Sie soeben aufgedeckt haben tun Sie es schnell und klicken Sie auf ""kaufen"" - Sie haben dafür 20 Sekunden. Sie können aber eine Stunde oder einen Tag warten um zu sehen ob der Preis noch weiter fällt. Das Aufdecken des Preises von anderen Benutzern reduziert den Preis kontinuierlich weiter. Denken Sie jedoch daran dass wenn Sie zu lange warten jemand wird schneller sein als Sie!. ;5";"0" 3914;"auction_desc_22297";"MacBook 12" 256GB - Space Gray
    256 GB pamięci masowej flash z magistralą PCIe na płycie głównejDwurdzeniowy procesorIntel Core m3 1,1 GHzTurbo Boost do 2,2 GHz8 GB pamięci RAMIntel HD Graphics 515
    Zawartość opakowaniaMacBookZasilacz USB-C o mocy 29 WPrzewód zasilający USB-C (2 m)
    Cena zawiera koszt przesyłki."\'"5";"0"';

    $regex = '#"(?<quotes>[^"]*)"#';

    preg_match_all($regex, $string, $matches);

    var_dump($matches['quotes']);
试试这个:

<?php

    $string = '1;"admin_loginIncorrect";"Podane hasło jest nieprawidłowe";"1";"0" 2;"admin_logOut";"Wyloguj";"1";"0" 3786;"tutorial_text_3";"Wenn Sie ein Produkt kaufen möchten dessen Preis Sie soeben aufgedeckt haben tun Sie es schnell und klicken Sie auf ""kaufen"" - Sie haben dafür 20 Sekunden. Sie können aber eine Stunde oder einen Tag warten um zu sehen ob der Preis noch weiter fällt. Das Aufdecken des Preises von anderen Benutzern reduziert den Preis kontinuierlich weiter. Denken Sie jedoch daran dass wenn Sie zu lange warten jemand wird schneller sein als Sie!. ;5";"0" 3914;"auction_desc_22297";"MacBook 12" 256GB - Space Gray
    256 GB pamięci masowej flash z magistralą PCIe na płycie głównejDwurdzeniowy procesorIntel Core m3 1,1 GHzTurbo Boost do 2,2 GHz8 GB pamięci RAMIntel HD Graphics 515
    Zawartość opakowaniaMacBookZasilacz USB-C o mocy 29 WPrzewód zasilający USB-C (2 m)
    Cena zawiera koszt przesyłki."\'"5";"0"';

    $regex = '#"(?<quotes>[^"]*)"#';

    preg_match_all($regex, $string, $matches);

    var_dump($matches['quotes']);

你可以尝试做一些类似的事情,比如,继续拆分;(因为这看起来确实是定界符),然后把前导和尾随“。”这会给你想要的数据,包括中间的引文。如果这样的话,我可以写出一个更好的答案。你可以试着去做一些类似的事情;(因为这似乎是定界符),然后把前导和尾随“。”这会让你得到你想要的数据,包括中间的引号。如果这行得通的话,我可以写一个更好的答案。它跳过了第二个值“Podane hasło jest nieprawidłowe”,事实上它跳过了更多的值。是的,奇怪的非标准字符,正则表达式只需要稍微调整一下。它跳过了很多我们需要比
\w+
更聪明的东西,但“”双引号[12194]=>string(6)“kaufen”仍然存在问题它跳过了第二个值“Podane hasło jest nieprawidłowe”事实上它跳过了更多的值是的,奇怪的非标准字符,正则表达式只需要调整一点仍然相同。它跳过了很多我们需要比
\w+
更聪明的东西,但“”双引号[12194]=>string(6)“考芬”仍然存在问题