php - How to combine array that has same key? -
I get this array, but I want to show me the key and all the subtabs of that key, I do not have it all the time To repeat the desired key, I need that the key only shows one and all other units which have the same key under this one.
array (2) {[0] => Array (1) {["A"] = & gt; String (2) "Test 1"} [1] = & gt; Array (1) {["A"] = & gt; String (2) "Test 1"}} I array (2) {[0] = & gt; Array (1) {["A"] = & gt; String (2) "Test 1", string (2) "Test 2"}} < P> use the following: $ return = array_merge_recursive ($ array, ...); In your case, :
$ return = array_merge_recursive ($ array [0], $ array [1]); But I guess you need a more dynamic solution, I'll prepare it now.
$ return = call_user_func_array ('array_merge_recursive' $ array);
Comments
Post a Comment