Check quotes in a file : preg_match « String « PHP
- PHP
- String
- preg_match
Check quotes in a file
<?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);
?>
Related examples in the same category