Php 移除外部阵列并更改显示阵列

Php 移除外部阵列并更改显示阵列,php,laravel,multidimensional-array,Php,Laravel,Multidimensional Array,如果在一个数组中有一个数组,那么如何删除此laravel代码中的外部数组。当前返回数组 return view($this->_viewDefaultFile) ->with('id', $this->_formId) ->with('class', $this->_formClass) ->with('elements', $this->_formElements) ->with('Man

如果在一个数组中有一个数组,那么如何删除此laravel代码中的外部数组。当前返回数组

 return view($this->_viewDefaultFile)
       ->with('id', $this->_formId)
       ->with('class', $this->_formClass)
       ->with('elements', $this->_formElements)
       ->with('ManageJs', $this->_formManageJs);
当前结果

[
  0 {
    "id": "id",
    "group": 0,
    "type": "hidden",
    "label": "",
    "options": [

    ],
    "value": "1"
  },
  1 {
    "id": "taskstream",
    "group": 0,
    "type": "text",
    "label": "Task Stream",
    "options": {
      "class": "",
      "validation": "required"
    },
    "value": "System down for maintenance"
  }
]
但优先产出

[
      id {
        "id": "id",
        "group": 0,
        "type": "hidden",
        "label": "",
        "options": [

        ],
        "value": "1"
      },
      taskstream {
        "id": "taskstream",
        "group": 0,
        "type": "text",
        "label": "Task Stream",
        "options": {
          "class": "",
          "validation": "required"
        },
        "value": "System down for maintenance"
      }
    ]
因此,我想返回(ID)具有密钥的数组。请提供帮助。

这是:

$array = []; // your array
$new_array = [];
foreach ($array as $item) {
    $new_array[$item->id] = $item;
}

迭代第一个数组并创建第二个。你能举个例子吗。我有一个想法,但很难实现。