3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $merged_array = array(); $final_array = array(); $json[123]["data"]["categories"] = array( array( 'id' => '2', 'description' => 'Single-player' ), array( 'id' => '1', 'description' => 'Multi-player' ), array( 'id' => '9', 'description' => 'Co-op' ), array( 'id' => '22', 'description' => 'Steam Achievements' ), array( 'id' => '28', 'description' => 'Full controller support' ) ); $json[456]["data"]["categories"] = array( array( 'id' => '21', 'description' => 'Downloadable Content' ) ); $json[786]["data"]["categories"] = array( array( 'id' => '31', 'description' => 'Downloadable Content' ) ); $json[058]["data"]["categories"] = array( array( 'id' => '41', 'description' => 'Downloadable Content' ) ); foreach($json as $key=>$value){ array_push($merged_array,$json[$key]["data"]["categories"]); } foreach($merged_array as $value){ foreach($value as $val){ array_push($final_array,$val); } } print_r($final_array); ?>
based on X61bE
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0
Array ( [0] => Array ( [id] => 2 [description] => Single-player ) [1] => Array ( [id] => 1 [description] => Multi-player ) [2] => Array ( [id] => 9 [description] => Co-op ) [3] => Array ( [id] => 22 [description] => Steam Achievements ) [4] => Array ( [id] => 28 [description] => Full controller support ) [5] => Array ( [id] => 21 [description] => Downloadable Content ) [6] => Array ( [id] => 31 [description] => Downloadable Content ) [7] => Array ( [id] => 41 [description] => Downloadable Content ) )