PHP add elements to multidimensional array with array_push

前端 未结 3 506
南旧
南旧 2020-11-28 23:13

I have a multidimensional array $md_array and I want to add more elements to the sub-arrays recipe_type and cuisine coming from a loop that reads data from a table.

3条回答
  •  伪装坚强ぢ
    2020-11-28 23:57

    As in the multi-dimensional array an entry is another array, specify the index of that value to array_push:

    array_push($md_array['recipe_type'], $newdata);
    

提交回复
热议问题