chanchelkumar Posted December 12, 2007 Share Posted December 12, 2007 Hi friends, I have a bunch of variables, one for each of our employees. Included in these variables are phone numbers: work phone in format (XXX) XXXXXXX etc. How can I write a script that searches for and extracts the phone numbers from these variables? Quote Link to comment https://forums.phpfreaks.com/topic/81325-solved-to-get-phone-number-from-datas/ Share on other sites More sharing options...
rajivgonsalves Posted December 12, 2007 Share Posted December 12, 2007 Could you post some code please it will be helpful Quote Link to comment https://forums.phpfreaks.com/topic/81325-solved-to-get-phone-number-from-datas/#findComment-412748 Share on other sites More sharing options...
chanchelkumar Posted December 12, 2007 Author Share Posted December 12, 2007 Could you post some code please it will be helpful sorry man.... i am searching for a code and you want code???/ Quote Link to comment https://forums.phpfreaks.com/topic/81325-solved-to-get-phone-number-from-datas/#findComment-412754 Share on other sites More sharing options...
rajivgonsalves Posted December 12, 2007 Share Posted December 12, 2007 well you said variables ? what variables from where are they fetch... please elaborate. Quote Link to comment https://forums.phpfreaks.com/topic/81325-solved-to-get-phone-number-from-datas/#findComment-412755 Share on other sites More sharing options...
chanchelkumar Posted December 12, 2007 Author Share Posted December 12, 2007 Ok... suppose $check="front street Unique historical building Office Space - 1925 square foot + Call xxx-xxx-xxxx (18 Nov 2007) (xxx) xxxxxxx, - xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; this value is coming from database table.... and i want to take this phone number from that varible... i tried with preg_match... $US_PHONE_PREG ="/^(?:\+?1[\-\s]?)?(\(\d{3}\)|\d{3})[\-\s\.]?"; //area code $US_PHONE_PREG.="(\d{3})[\-\.]?(\d{4})/"; // seven digits preg_match($US_PHONE_PREG,$check, $matches); echo "</br>"; echo $matches[1]; it returns me no value... Quote Link to comment https://forums.phpfreaks.com/topic/81325-solved-to-get-phone-number-from-datas/#findComment-412758 Share on other sites More sharing options...
papaface Posted December 12, 2007 Share Posted December 12, 2007 I dont think your employees would appreciate they're telephone number and address being pasted across the internet Quote Link to comment https://forums.phpfreaks.com/topic/81325-solved-to-get-phone-number-from-datas/#findComment-412759 Share on other sites More sharing options...
chanchelkumar Posted December 12, 2007 Author Share Posted December 12, 2007 I dont think your employees would appreciate they're telephone number and address being pasted across the internet Quote Link to comment https://forums.phpfreaks.com/topic/81325-solved-to-get-phone-number-from-datas/#findComment-412763 Share on other sites More sharing options...
chanchelkumar Posted December 12, 2007 Author Share Posted December 12, 2007 Any one here to help me please.... Quote Link to comment https://forums.phpfreaks.com/topic/81325-solved-to-get-phone-number-from-datas/#findComment-412850 Share on other sites More sharing options...
effigy Posted December 12, 2007 Share Posted December 12, 2007 Based on your data set: <pre> <?php $data = 'front street Unique historical building Office Space - 1925 square foot + Call xxx-xxx-xxxx (18 Nov 2007) (xxx) xxxxxxx, - xxxxxxxxxxxxxxx'; preg_match_all('/ \(?\d{3}\)? \D? \d{3} \D? \d{4} /x', $data, $matches); print_r($matches); ?> </pre> Tip: Avoid being excessive in smilies () and punctuation?!?!. It's unnecessary. Quote Link to comment https://forums.phpfreaks.com/topic/81325-solved-to-get-phone-number-from-datas/#findComment-412857 Share on other sites More sharing options...
chanchelkumar Posted December 12, 2007 Author Share Posted December 12, 2007 Thanks.... effigy... It works!!!! sorry for the over smilies...(That's all belong to my situation...) Quote Link to comment https://forums.phpfreaks.com/topic/81325-solved-to-get-phone-number-from-datas/#findComment-412875 Share on other sites More sharing options...
ober Posted December 13, 2007 Share Posted December 13, 2007 Normally we don't provide full code examples without some work from you. Unless you don't know anything about PHP, we're here to help you when you get stuck with the code, not write it for you. Also, please be careful about using personal/work information about locations and/or phone numbers in the future. I've removed all the references from the thread. It may not bother you, but others could use the information in a malicious manner. Quote Link to comment https://forums.phpfreaks.com/topic/81325-solved-to-get-phone-number-from-datas/#findComment-414022 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.