$re = '@[^<]*<div[^>]*id="number-third-digit-space"[^<]*<div[^>]*class="[^"]*(?<="|\s)contact-phone-prefix(?="|\s[^>]*)">(?<mobile>\d+).*?(\d+)@ims';
$str = '<div class="contact-phone-icon sprite_view_icn_CnPhone"></div>
<div id="number-third-digit-space" style="display:none">
<div class="contact-phone-prefix">017</div>
<div class="contact-phone-number">3816648</div>
</div>
<div id="number-second-digit-space" style="display:none">
<div class="contact-phone-prefix">01</div>
<div class="contact-phone-number">73816648</div>
</div>';
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