PHP add elements to multidimensional array with array_push

if you want to add the data in the increment order inside your associative array you can do this: $newdata = array ( ‘wpseo_title’ => ‘test’, ‘wpseo_desc’ => ‘test’, ‘wpseo_metakey’ => ‘test’ ); // for recipe $md_array[“recipe_type”][] = $newdata; //for cuisine $md_array[“cuisine”][] = $newdata; this will get added to the recipe or cuisine depending on … Read more

Why does Array.prototype.push return the new length instead of something more useful?

I understand the expectation for array.push() to return the mutated array instead of its new length. And the desire to use this syntax for chaining reasons. However, there is a built in way to do this: array.concat(). Note that concat expects to be given an array, not an item. So, remember to wrap the item(s) … Read more