<?php
echo "hello\x08";
?>
即将出现
您好
我正在使用xampp作为localhost
$reply='{';
while($row=$this->conx->fetch_array($result)){
$user=new user();
$fullname=$user->get('fullname','id',$row['posted_by']);
$now=getdat($row['posted_on']);
$reply.='"count'.$count.'":{"id":'.$row['post_id'].',"user":"'.$fullname['fullname'].'","msg":"'.$row['msg'].'","at":"'.$now.'"},';
}
$reply.='}';
return $reply;}
如何从回复中删除最后一个','?
答案 0 :(得分:1)
试一试。
$reply = rtrim($reply,",");
使用您的示例
$reply='{';
while($row=$this->conx->fetch_array($result)){
$user=new user();
$fullname=$user->get('fullname','id',$row['posted_by']);
$now=getdat($row['posted_on']);
$reply.='"count'.$count.'":{"id":'.$row['post_id'].',"user":"'.$fullname['fullname'].'","msg":"'.$row['msg'].'","at":"'.$now.'"},';
}
$reply.='}';
return rtrim($reply,",");}