How can I clear the tabs in a string?

Source: Internet
Author: User
Tags one more line
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.