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));

preferences:
31.49 ms | 407 KiB | 5 Q