請問怎麼清除字串中的定位字元這些

來源:互聯網
上載者:User
$buf[10] = str_replace("\r\n", '', $buf[10]); //清除分行符號
$buf[10] = str_replace("\n", '', $buf[10]); //清除分行符號
$buf[10] = str_replace("\t", '', $buf[10]); //清除定位字元

以上我用了,不管用,以下連結是樣本檔案的下載,是csv格式的,有個地址包含了定位字元這些,需要刪除掉

http://pan.baidu.com/s/1sjEcrM1


回複討論(解決方案)

$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 )
並沒有看到定位字元

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;}


我現在是這樣的,輸出就多了一行

現在輸出txt檔案多了一行,用notepad++看是有多了一個分行符號的,請問怎麼查這個分行符號是什嗎??

str_replace(array("\r\n", "\r", "\n"), " ", $buf[10]); 搞定了

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.