3v4l.org

run code in 300+ PHP versions simultaneously
<?php function wordSafeSplit(string $text, int $pieces = 2) { $wordsPerPiece = ceil(str_word_count($text) / $pieces); return preg_split( "~([^\w'-]*[\w'-]+[^\w' -]*){{$wordsPerPiece}}\K\s?~", $text, $pieces ); } $text = "The Quick : Brown Fox Jumped Over The Lazy / Dog"; var_export(wordSafeSplit($text));
Output for git.master_jit, git.master, rfc.property-hooks
array ( 0 => 'The Quick : Brown Fox Jumped', 1 => 'Over The Lazy / Dog', )

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:
81.84 ms | 405 KiB | 5 Q