php - Convert collection of array to object -
i'm pushing array data. how can return object this:
"data": [ { "apartment": { { "id": xxx, "show": "xxx, }, { "id": xxx, "show": "xxx", },
and not this:
"data": [ { "apartment": { "0": { "id": xxx, "show": "xxx, }, "1" : { "id": xxx, "show": "xxx", },
this code:
data[] = array("id" => 1)
will add named array data array.
data = [ {"id" => 1} ]
if want data named array, should add "id" => 1
this:
data[1] = {"id" => 1}
this result in:
data = { 1 => {"id" => 1} }
Comments
Post a Comment