php中 函数调用的问题

来源:百度知道 编辑:UC知道 时间:2024/05/26 18:05:51
<?php
function htmtocode($content) {
$content = str_replace("\n", "<br>", str_replace(" ", " ", $content));
return $content;
?>

这个函数我是这样调用 的
<?php
echo "<td width=10%><font color=red>内容:</font>";
echo htmtocode($new['content']);
echo "</td>";
?>
可是我的内容就是不换行啊!!是什么问题呢??请指教!!

你检查你输入的内容有没有回车
也就是$new['content']这个,你先输出看有没有\n

你的程序没问题,函数也没问题

$new['content']
这个应该是数组,
str_replace不能用你这种方法搞数组里的内容.