tags:

views:

51

answers:

1
if (preg_match('/^([0-9]( |-)?)?(\(?[0-9]{3}\)?|[0-9]{3})( |-)?([0-9]{3}( |-)?[0-9]{4}|[a-zA-Z0-9]{7})$/', $buffer, $matches));
{
    $variable = ?;
}
+1  A: 

see: http://php.net/manual/en/function.preg-match.php

In your case the $matches array holds what you are looking for. It is always a good idea to check the documentation first. Especially for something documented well.

ghills