hammadtariq Posted September 28, 2009 Share Posted September 28, 2009 Hello Guys, I have a task in hand in which I am getting strings which are in fact subjects of emails and they are like "This should be done! 568975/12/tinup" "456789 is your reference" "I am in 456789 area" All I need is to take out consecutive six matching numbers and that will be my reference number. Reference number is always in six digits and I need to take out any occurance of six digit numbers and stripping out everything else. I considered using strspn() but thats not working I guess that is not for search like this and I am really bad in using preg_match, can any one help me please? Quote Link to comment Share on other sites More sharing options...
trq Posted September 28, 2009 Share Posted September 28, 2009 $s = 'This should be done! 568975/12/tinup'; preg_match('/([0-9]){6}/', $s, $m); echo $m[0]; Quote Link to comment Share on other sites More sharing options...
hammadtariq Posted September 29, 2009 Author Share Posted September 29, 2009 thanks thorpe, that worked like a pro.. Quote Link to comment 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.