fork download
  1. <?php
  2.  
  3. $string = 'command run --first-arg="something here" --second-arg="something here" --last-arg';
  4. print_r(preg_split('/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/', $string));
Success #stdin #stdout 0.01s 23964KB
stdin
Standard input is empty
stdout
Array
(
    [0] => command
    [1] => run
    [2] => --first-arg="something here"
    [3] => --second-arg="something here"
    [4] => --last-arg
)