php去掉轉(zhuǎn)義字符的方法:首先找到需要去除轉(zhuǎn)義字符并打開源代碼;然后返回一個去除轉(zhuǎn)義反斜線后的字符串,代碼為【string stripslashes ( string $str )】。
php去掉轉(zhuǎn)義字符的方法:
string stripslashes ( string $str )
返回一個去除轉(zhuǎn)義反斜線后的字符串(' 轉(zhuǎn)換為 ' 等等)。雙反斜線(\)被轉(zhuǎn)換為單個反斜線()。
stripslashes()
是非遞歸的。如果你想要在多維數(shù)組中使用該函數(shù),你需要使用遞歸函數(shù)。
<?php function stripslashes_deep($value) { $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value); return $value; } // 范例 $array = array("f\'oo", "b\'ar", array("fo\'o", "b\'ar")); $array = stripslashes_deep($array); // 輸出 print_r($array); ?>
以上輸出:
Array ( [0] => f'oo [1] => b'ar [2] => Array ( [0] => fo'o [1] => b'ar ) )
相關(guān)學(xué)習(xí)推薦:php編程(視頻)