php如何将字符串中的尀n变成真正的换行符?

2025-03-23 02:34:48
推荐回答(2个)
回答1:

php有个函数

echo nl2br("foo isn't\n bar");
?>

这个函数自动 把\n换成br

回答2:

$str = "abc\ndef";
$order = "\n";
$replace = "
";
$newstr = str_replace($order,$replace,$str);

echo $newstr;
?>