在php中,要显示数据库中的信息,有时需要对格式进行转化,我用一段小程序
实现了自动格式化,代码如下: 假设要显示数据字段mytxt.
$sql="select * from mydbf where content_id=".$id;
$result=mysql_query($sql);
$row = mysql_fetch_array($result);
if($row[mytxt]){
$str_array=explode("\n",$news_show[mytxt]);
while(list($key,$value)=each($str_array))
{ while(ord($value)==161) $value=substr($value,1);
echo "    ".trim($value)."<br>";
} } |
|