3v4l.org

run code in 500+ PHP versions simultaneously
<?php $words = ["hi", "my", "name", "is", "john doe"]; $result = []; foreach($words as $word) { $result = array_merge($result, explode(' ', $word)); } var_dump($result);
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
array(6) { [0]=> string(2) "hi" [1]=> string(2) "my" [2]=> string(4) "name" [3]=> string(2) "is" [4]=> string(4) "john" [5]=> string(3) "doe" }

preferences:
99.05 ms | 1267 KiB | 4 Q