Php 删除json中的括号?

Php 删除json中的括号?,php,json,Php,Json,对于json处理,如何去掉下面的括号 [{"success":true,"filename":"bialding_and_rebialding_plymouth02.jpg"},{"success":true,"filename":"bialding_and_rebialding_plymouth03.jpg"},{"success":true,"filename":"bialding_and_rebialding_plymouth04.jpg"}] 上面的结果由下面的类处理成一个数组 fun

对于json处理,如何去掉下面的括号

[{"success":true,"filename":"bialding_and_rebialding_plymouth02.jpg"},{"success":true,"filename":"bialding_and_rebialding_plymouth03.jpg"},{"success":true,"filename":"bialding_and_rebialding_plymouth04.jpg"}]
上面的结果由下面的类处理成一个数组

function handle_upload($upload_directory)
    {
        # Loop the code according to the number of files.
        for($i = 1; $i <= $this->total; $i++)
        {
            ...

            if ($this->file->save($upload_directory.$name_filtered.'.'.$file_extension , $i-1))
            {
                $message[] = array('success'=>true,'filename'=>$name_filtered.'.'.$file_extension);
            }
            else 
            {
                $message[] = array('error'=> 'Could not save uploaded file.' . 'The upload was cancelled, or server error encountered');
            }
        }

        return $message;
    }
但我只需要在我的结果中,不带括号

{"success":true,"filename":"bialding_and_rebialding_plymouth02.jpg"},{"success":true,"filename":"bialding_and_rebialding_plymouth03.jpg"},{"success":true,"filename":"bialding_and_rebialding_plymouth04.jpg"}

str_replace(数组('[',']'),'',htmlspecialchars(json_encode($result),ENT_NOQUOTES))

通过在函数中执行以下操作,可以拉出json并返回它:

return $message[0];  //  only json
或者,您可以将其全部退回,然后将其删除:

$uploader = new uploader();
$result1 = $uploader->handle_upload('uploads/');
$result2 = $result[0];

如果没有括号,json字符串将无效。JSON字符串只能包含一个值。加上括号,它是一个数组或对象。没有括号,它是一系列单独的逗号分隔对象-无效。这不再是有效的json。为什么不使用
[]
?你将如何处理生成的字符串?我的错误-我认为括号应该在那里。我是json新手-对不起@lauthiamkok:括号应该在那里,否则无效。好家伙,tks!!
$uploader = new uploader();
$result1 = $uploader->handle_upload('uploads/');
$result2 = $result[0];