3v4l.org

run code in 300+ PHP versions simultaneously
<?php $re = '/^\h*+\K.{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.13
array ( 0 => 'this is a', 1 => 'this is a', 2 => 'a', 3 => 'b', 4 => 'c', )

preferences:
73.55 ms | 406 KiB | 5 Q