我只是想知道如何将查询结果的键转换为数字。这是我对示例的查询结果:
$result = [{
"lat": "43289043208",
"lng": "-3890423802"
},...]
我想要的是
$result = [{
0: "43289043208",
1: "-3890423802"
},...]
任何帮助将不胜感激。
答案 0 :(得分:0)
您可以使用array_values()方法。
并迭代结果数组
$newArray = [];
foreach(json_decode($result) as $res)
{
$newArray[] = array_values($res);
}
答案 1 :(得分:0)
最后,我用这个,现在解决了
$table_data = DB::table($table)->select(DB::raw("$lat_field as '0'"), DB::raw("$lng_field as '1'"))->get();