fork(2) download
  1. <?php
  2. $string = "(731) some text here with number 2 (220) some 54 number other text here";
  3.  
  4. preg_match_all("/\((\d{3})\) *([^( ]*(?> +[^( ]+)*)/", $string, $matches);
  5. $result = array_combine($matches[1], $matches[2]);
  6.  
  7. print_r($result);
  8.  
  9. ?>
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
Array
(
    [731] => some text here with number 2
    [220] => some 54 number other text here
)