fork download
  1. <?php
  2.  
  3. $input = "Sum(1, 5, 7)";
  4.  
  5. preg_match_all('#(\w+)\((.*?)\)#', $input, $m);
  6.  
  7. print_r($m);
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
Array
(
    [0] => Array
        (
            [0] => Sum(1, 5, 7)
        )

    [1] => Array
        (
            [0] => Sum
        )

    [2] => Array
        (
            [0] => 1, 5, 7
        )

)