Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/257.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从laravel中的过程中获取结果-从响应中删除方括号_Php_Sql_Arrays_Stored Procedures_Laravel - Fatal编程技术网

Php 从laravel中的过程中获取结果-从响应中删除方括号

Php 从laravel中的过程中获取结果-从响应中删除方括号,php,sql,arrays,stored-procedures,laravel,Php,Sql,Arrays,Stored Procedures,Laravel,这是我的程序 $result = DB::select('call FastBooking(?,?)',array(Input::get('Lat'),Input::get('Long'))); return $result; 当我执行并试图返回$result时,我得到的结果是 [{"AutoId":4,"DriverId":4,"distance":103.81984745881},{"AutoId":3,"DriverId":3,"distance":373.5531833859},{"A

这是我的程序

$result = DB::select('call FastBooking(?,?)',array(Input::get('Lat'),Input::get('Long')));
return $result;
当我执行并试图返回
$result
时,我得到的结果是

[{"AutoId":4,"DriverId":4,"distance":103.81984745881},{"AutoId":3,"DriverId":3,"distance":373.5531833859},{"AutoId":1,"DriverId":1,"distance":7528.7211073364},{"AutoId":2,"DriverId":2,"distance":7560.0258965718}]
当我试图打印($result)时我得到以下结果

Array ( [0] => stdClass Object ( [AutoId] => 4 [DriverId] => 4 [distance] => 103.81984745881 ) [1] => stdClass Object ( [AutoId] => 3 [DriverId] => 3 [distance] => 373.5531833859 ) [2] => stdClass Object ( [AutoId] => 1 [DriverId] => 1 [distance] => 7528.7211073364 ) [3] => stdClass Object ( [AutoId] => 2 [DriverId] => 2 [distance] => 7560.0258965718 ) ) Tarrif is 1 Day is 4 Time is 4Current Date is 2015-02-26 - Count : 0
我只是想得到那份工作

{"AutoId":4,"DriverId":4,"distance":103.81984745881},{"AutoId":3,"DriverId":3,"distance":373.5531833859},{"AutoId":1,"DriverId":1,"distance":7528.7211073364},{"AutoId":2,"DriverId":2,"distance":7560.0258965718}
也就是说我不想把方括号放在外面

我怎么会这样


(不关心解码,我只想删除这里的
[]
方括号)

我看不出为什么有人想要一个断开的json字符串,但你可以尝试这样做

str_replace (array('[', ']'), '' , $data);

我不确定您使用这些数据的目的,但我强烈建议您保留有效的json

您有一个对象数组。外部的括号是解码所必需的。不,我不直接解码这个,我有另一组对象,我将插入其中,所以我只需要删除
[]
,对于这种情况,得到相同的结果:(
:[{“AutoId”:4,“DriverId”:4,“distance”:103.81984745881},{“AutoId”:3,“DriverId”:3,“distance”:373.5531833859},{“AutoId”:1,“DriverId”:1,“distance”:7528.7211073364},{“AutoId”:2,“DriverId”:2,“distance”:7560.0258965718}]