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? Link to comment https://forums.phpfreaks.com/topic/175789-solved-searching-for-consecutive-six-0-9-numbers-in-a-string/ 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]; Link to comment https://forums.phpfreaks.com/topic/175789-solved-searching-for-consecutive-six-0-9-numbers-in-a-string/#findComment-926318 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.. Link to comment https://forums.phpfreaks.com/topic/175789-solved-searching-for-consecutive-six-0-9-numbers-in-a-string/#findComment-926989 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.