$re = '/^6(?:9\d{7}|5[5-9]\d{6})$/m';
$str = '# Invalid
61234
6123456789
6word7890
12688684749
# MTN
688684749
678684749
651684749
652684749
653684749
654684749
# Orange
698684749
655684749
656684749
657684749
658684749';
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