3v4l.org

run code in 300+ PHP versions simultaneously
<?php $re = '/^.{0,11}\S(?!\S)/m'; $str = 'this is a test sentence this is a test sentence a b c'; preg_match_all($re, $str, $matches); var_export($matches[0]);
Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.14
array ( 0 => 'this is a', 1 => ' this', 2 => 'a', 3 => ' b', )

preferences:
87.11 ms | 406 KiB | 5 Q