0
<?php
echo "hello\x08";
?>

对此的输出是

你好

我正在以本地主机的身份使用 xampp

$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;}

如何从回复中删除最后一个“,”?

4

1 回答 1

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,",");}
于 2013-06-22T14:20:13.230 回答