3v4l.org

run code in 300+ PHP versions simultaneously
<?php $unflattened_array = [ '["2", "3"]', '["4"]', '["4", "3"]' ]; $flattened_array = []; foreach ($unflattened_array as $items) { array_push($flattened_array, ...json_decode($items)); } $flattened_array = array_unique($flattened_array); var_dump($flattened_array);
Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
array(3) { [0]=> string(1) "2" [1]=> string(1) "3" [2]=> string(1) "4" }

preferences:
67.45 ms | 406 KiB | 5 Q