fork download
  1. <?php
  2. $pattern = "/\[VAR:(.*?)\]/";
  3. $string = "[VAR:one] once apon a time [VAR:two]. And then there was the time that [VAR:three] went to [VAR:four]";
  4. preg_match_all ( $pattern , $string, $matches );
  5.  
  6. print_r ( $matches );
  7.  
  8. ?>
Success #stdin #stdout 0.02s 13064KB
stdin
Standard input is empty
stdout
Array
(
    [0] => Array
        (
            [0] => [VAR:one]
            [1] => [VAR:two]
            [2] => [VAR:three]
            [3] => [VAR:four]
        )

    [1] => Array
        (
            [0] => one
            [1] => two
            [2] => three
            [3] => four
        )

)