fork(1) download
  1. <?php
  2.  
  3. $text = "i did";
  4. preg_match("~(?|(did) (.+)|(.+) (did))~", $text, $match);
  5. print_r($match);
  6.  
  7. echo "<br>";
  8.  
  9. $text = "did i";
  10. preg_match("~(?|(did) (.+)|(.+) (did))~", $text, $match);
  11. print_r($match);
Success #stdin #stdout 0.02s 52432KB
stdin
Standard input is empty
stdout
Array
(
    [0] => i did
    [1] => i
    [2] => did
)
<br>Array
(
    [0] => did i
    [1] => did
    [2] => i
)