3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "This is my test case for an example"; function splitStrByWords($sentence, $wordCount=2) { $words = array_chunk( explode(' ', $sentence), $wordCount ); return array_map( 'implode', $words, array_fill(0, sizeof($words), ' ') ); } var_export(splitStrByWords($string));
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught TypeError: implode(): Argument #2 ($array) must be of type ?array, string given in /in/RKFkV:10 Stack trace: #0 [internal function]: implode(Array, ' ') #1 /in/RKFkV(10): array_map('implode', Array, Array) #2 /in/RKFkV(16): splitStrByWords('This is my test...') #3 {main} thrown in /in/RKFkV on line 10
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
60.69 ms | 406 KiB | 5 Q