<p><span class="Title">Arcohe Elementary School</span><br />Elementary School<br />County: Sacramento<br />Area: A</p><p><strong>Mark Cornfield</strong> <br />11755 Ivie Rd.<br />Herald, CA 95638<br /> (209) 748-2609<br /><a href="http://www.arcohe.lodinet.com" target="_blank">www.arcohe.lodinet.com</a><br /><a href="mailto:mcornfield@yahoo.com">mcornfield@yahoo.com</a></p><p> HTML: I want to find phone number and email from above I tied following code to fetch phone number but failed, can anyone help me out? $pattern = '/<br \/>(.*)<br \/><a href=/'; //To get school preg_match_all($pattern, $myData, $matche1); PHP: Thanks
Try this code <?php $myData = '<p><span class="Title">Arcohe Elementary School</span><br />Elementary School<br />County: Sacramento<br />Area: A</p><p><strong>Mark Cornfield</strong> <br />11755 Ivie Rd.<br />Herald, CA 95638<br /> (209) 748-2609<br /><a href="http://www.arcohe.lodinet.com" target="_blank">www.arcohe.lodinet.com</a><br /><a href="mailto:mcornfield@yahoo.com">mcornfield@yahoo.com</a></p><p>'; $pattern = '/\(\d{3}\)\s*\d{3}\-\d{4}/'; //To get school preg_match_all($pattern, $myData, $matche1); echo $matche1[0][0]; ?> Code (markup): This will give you phone number You can print_r($matche1) to see all selected phone numbers