3v4l.org

run code in 300+ PHP versions simultaneously
<?php function join_words($words) { $return = []; for ($i=0; $i < count($words); $i++) { $return[] = implode(' ', array_slice($words, 0, $i+1)); } return $return; } $words = ['THIS', 'IS', 'AN', 'EXAMPLE']; $result = []; $result = array_merge($result, join_words($words)); $result = array_merge($result, join_words(array_reverse($words))); print_r($result);

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
154.91 ms | 2182 KiB | 15 Q