I have this code:
$arr = [];
$arr['into']['box'] = 1;
return $arr;
But it returns this:
{
"into": {
"box": 1
}
}
As you can see it should be array, not object!!
I searched a lot but I didn't find anything.
Help me and give me the code or the tip please.
In addition to returning strings from your routes and controllers, you may also return arrays. The framework will automatically convert the array into a JSON response:
The same is true for models, and collections:
Did you know you can also return Eloquent collections from your routes or controllers? They will automatically be converted to JSON. Give it a shot!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.