$re = '/^(0|\+98)9[0-9]{9}$/mi';
$str = '09156987452
09908472853
09153610882365
09158645287
+9814756842
+980915874622
+989908472853
+981283547
9836587498
+986859554
+989158497858
+9812457868
02154091563214587
12409156032145
091596356478
+982654789652
023654d
5588
879 091586424569
+9878546
+9999999999999
+989153610883
0915603551555555555
';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php