3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $var = <<<DATA This is "some data" with some "quoted \"strings" DATA; $expr = '/\s+(?=[^\s]+|"((?:[^"\\\\]|\\\\.)*)")/'; var_dump(preg_split($expr, $var, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE));
based on ToWOe
Output for 4.3.0 - 5.6.21, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(8) { [0]=> string(4) "This" [1]=> string(2) "is" [2]=> string(5) ""some" [3]=> string(5) "data"" [4]=> string(4) "with" [5]=> string(4) "some" [6]=> string(7) ""quoted" [7]=> string(10) "\"strings"" }