Voting

: five plus one?
(Example: nine)

The Note You're Voting On

from_php at puggan dot se
8 years ago
Setting the $escape parameter dosn't return unescaped strings, but just avoid splitting on a $delimiter that have an escpae-char infront of it:

<?php
$tmp_file
= "/tmp/test.csv";
file_put_contents($tmp_file, "\"first\\\";\\\"secound\"");
echo
"raw:" . PHP_EOL . file_get_contents($tmp_file) . PHP_EOL . PHP_EOL;

echo
"fgetcsv escaped bs:" . PHP_EOL;
$f = fopen($tmp_file, 'r');
while(
$r = fgetcsv($f, 1024, ';', '"', "\\"))
{
print_r($r);
}
fclose($f);
echo
PHP_EOL;

echo
"fgetcsv escaped #:" . PHP_EOL;
$f = fopen($tmp_file, 'r');
while(
$r = fgetcsv($f, 1024, ';', '"', "#"))
{
print_r($r);
}
fclose($f);
echo
PHP_EOL;
?>

<< Back to user notes page

To Top