3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $str = 'Hello how are you<br>Foo bar hello'; $array = preg_split( '/(?:(?<=\s)\s*|\b)|(<br>)/', $str, -1, PREG_SPLIT_DELIM_CAPTURE); var_dump( $array);
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(17) { [0]=> string(0) "" [1]=> string(5) "Hello" [2]=> string(1) " " [3]=> string(3) "how" [4]=> string(1) " " [5]=> string(3) "are" [6]=> string(1) " " [7]=> string(3) "you" [8]=> string(0) "" [9]=> string(4) "<br>" [10]=> string(0) "" [11]=> string(3) "Foo" [12]=> string(1) " " [13]=> string(3) "bar" [14]=> string(1) " " [15]=> string(5) "hello" [16]=> string(0) "" }