3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tests = [ (object) ['content' => 'one, two three four five, six seven'], (object) ['content' => 'foo'], (object) ['content' => 'fee fi, foe, fum, gimme those beans dude'], (object) ['content' => 'one a b c, two d e f g, three h, four i j, five k l m, six n, seven o p, eight q, nine r s t, ten u v w x, eleven y and z'], ]; foreach ($tests as $metakw) { var_dump( array_slice( preg_split( '/(?:[^, ]+\K *){1,3}[^,]*,? */', $metakw->content, 11, PREG_SPLIT_NO_EMPTY ), 0, 10 ) ); echo "\n---\n"; }

preferences:
46.29 ms | 1071 KiB | 5 Q