什么原因退格不能在PHP中工作?

时间:2013-06-22 14:08:48

标签: php backspace

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

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

1 个答案:

答案 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,",");}