php - Laravel 5.4 array remove key index -




in controller, statement generates array:

// sort region collection continent faster access in front end $finalregions = $regions->sortby('continent_id');   {      "0":{         "id":1,       "name":"alaska",       "image_x":227,       "image_y":117    },    "1":{         "id":5,       "name":"australian antartic territory",       "image_x":1187,       "image_y":1037 ....    } } 

how remove index resulting object, looks this:

[      {         "id":1,       "name":"alaska",       "image_x":227,       "image_y":117    },    {         "id":5,       "name":"australian antartic territory",       "image_x":1187,       "image_y":1037 ....    } ] 

this stored in field cast json in table class.

$res = []; foreach ($finalregions  $key => $value) {     $res[] = $value; }  // $res contains desired result 




wiki

Comments