假设你的text字段名为text
$text=ereg-replace("\n","<br>",$text);
echo $text;上面的意思是,将$text内的回车转换为<br>来表示,在html
中<br>就可以显示为回车.
$text=ereg-replace("\n","<br>",$text);
echo $text;上面的意思是,将$text内的回车转换为<br>来表示,在html
中<br>就可以显示为回车.
输出时根据需要用nl2br()函数
str_replace(" "," ",$content);
用这个函数方便的多啊~:)
或者复杂一点,定义一函数:function restr($content){
$string=str_replace(" "," ",$content);
$string=str_replace("\n","<br>",$string);
return $string;
}
还是没有表达清楚呀。
如果是“必须有两位小数点”
^(0|[1-9]\d{2})\.(\d{2})$
如果是“一不定有小数点”
^(0|[1-9]\d{2})$|^(0|[1-9]\d{2})\.(\d{2})$