2012-08-28 59 views
1

這是字符串,我試圖清理。只是不能擺脫` `字符從html字符串

'&#13;  &#13; <span>CR - CROPLAND</span>&#13;' 

這是我的調用語句:

trim(strip_tags(clean_string($leftTd->innerhtml()))) 

這是我試圖把它清理乾淨的功能,但它不能正常工作。

function clean_string($string){ 
    for($control = 0; $control < 32; $control++) { 
     $string = str_replace(chr($control), "", $string) ; 
    } 
    return $string ; 
} 

我也試過:

// $string = ereg_replace("[^A-Za-z0-9\-\./,']", " ",$string) ; 

,但它不工作。

幫助!我試圖擺脫&#13;。究竟是什麼。谷歌搜索不利於\

感謝

+0

的Ascii 0×13,或19:[(XOFF,與XON是TERM = 18的流量控制)](http://www.robelle.com/smugbook/ascii。 HTML) –

回答

0

你將不得不搜索字符串「&#13;」,因爲它是從字面上印像。它尚未被翻譯成它所代表的特殊字符。

str_replace("&#13;", "", $string); 

以上有效:

function clean_string($string){ 
    for($control = 0; $control < 32; $control++) { 
     $string = str_replace("&#$control;", "", $string) ; 
    } 
    return $string ; 
} 

注:角色13顯然是一個 「垂直製表」 ...有趣。 http://www.robelle.com/smugbook/ascii.html