1. 程式人生 > >php去除陣列或字串中特殊字元

php去除陣列或字串中特殊字元

去除陣列或是字串中的反斜槓

function stripslashes_deep($value)
    {
        $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
        //array_map() 函式將使用者自定義函式作用到陣列中的每個值上
        return $value;
    }
    //stripslashes()  去除反斜槓,也可使用
    //htmlspecialchars(),函式把預定義的字元轉換為 HTML 實體。
    //trim(),去除空白字元
    //htmlentities(),除上面htmlspecialchars字元外,還包括雙位元組字元顯示成編碼等。
    //可參考http://blog.csdn.net/jianglei421/article/details/5460810