fork download
  1. <?php
  2.  
  3. function retValues($input) {
  4. if (preg_match('~\((-?[0-9]+)\s*,\s*(-?[0-9]+)~', $input, $m)) {
  5. return array('left'=>$m[1], 'right'=>$m[2]);
  6. } else {
  7. return "";
  8. }
  9. }
  10.  
  11. $tuple = "(12342,43244)";
  12. print_r(retValues($tuple));
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
Array
(
    [left] => 12342
    [right] => 43244
)