How can I clear the tabs in a string? $ buf [10] = str_replace ("\ r \ n", '', $ buf [10]); // clear line breaks
$ Buf [10] = str_replace ("\ n", '', $ buf [10]); // clear the line break
$ Buf [10] = str_replace ("\ t", '', $ buf [10]); // clear the tab
I used the above, no matter how it is used, the following link is the download of the sample file, in csv format, there is an address containing the tab, these need to be deleted
Http://pan.baidu.com/s/1sjEcrM1
Reply to discussion (solution)
$fn = 'Order_2015-12-01_113045.csv';$s = file_get_contents($fn);preg_match_all('/[\x00-\x1f]/', $s, $m);print_r(array_map('bin2hex', $m[0]));
Array ([0] => 0a [1] => 0d [2] => 0a [3] => 0d [4] => 0a [5] => 0a)
No tab is displayed.
function lazada_csv_import($filePath){ $file_txt=""; $fp = fopen($filePath, 'r'); while($buf = fgetcsv($fp, '"', ';')){ $file_txt .= implode("\t",$buf)."\t\n"; } return $file_txt;}
I am doing this now, and there will be one more line of output
Now there is one more line in the output txt file, and there is an additional line break with notepad ++. how can I check this line break ??
Str_replace (array ("\ r \ n", "\ r", "\ n"), "", $ buf [10]); done