由于某种原因,搜索和替换部分功能无效。我的语法错了吗?
function display($data) {
$new = str_replace('<br />',"\n",$data);
$newer = htmlspecialchars($new);
$search = array('<b>', '</b>', '<i>', '</i>', '<u>', '</u>', '\r\n');
$replace = array('<b>', '</b>', '<i>', '</i>', '<u>', '</u>', '<br />');
$newest = str_replace($replace, $search, $newer);
return $newest;
}
答案 0 :(得分:0)
以这种方式尝试:
function display($data) {
$new = str_replace('<br />',"\n",$data);
$newer = htmlspecialchars($new);
$replace = array('<b>' => '<b>', '</b>' => '</b>', '<i>' => '<i>', '</i>'=> '</i>', '<u>' => '<u>', '</u>' => '</u>', '<br />' => '\r\n');
$newest = $newer;
foreach($replace as $rep => $find){
$newest = str_replace($rep , $find, $newest);
}
return $newest;
}