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

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -