PHP Check Quotes In File – String Function

<?php  $file = fopen("data.txt", "r") or die("Cannot open file!\n");  $lineNbr = 0;  while ($line = fgets($file, 1024)) {
    $lineNbr++;
    if (preg_match("/^[^\"]*\"([^\"]*|([^\"]*\"[^\"]*\"[^\"]*)*)$/", $line)) {
      echo "Found match at line " . $lineNbr . ":  " . $line;
    }
  }
  fclose($file);?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.