LuisAngel Posted April 14, 2010 Share Posted April 14, 2010 How do I extract 9 consecutive numbers from a URL like the following: http://itunes.apple.com/us/app/redlaser/id312720263?mt=8 In this example, the desired extraction is 312720263 Will something like the following work? <? preg_match('/([0-9]{9})/', $alphanum, $matches); $sequence = $matches[1]; ?> Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/198513-isolate-9-consecutive-numbers-from-url/ Share on other sites More sharing options...
thumrith Posted April 14, 2010 Share Posted April 14, 2010 I think using str_split will be fairly much easy for you for example print_r(str_split("test")); will result Array ( [0] => t [1] => e [2] => s [3] => t ) Quote Link to comment https://forums.phpfreaks.com/topic/198513-isolate-9-consecutive-numbers-from-url/#findComment-1041656 Share on other sites More sharing options...
Daniel0 Posted April 14, 2010 Share Posted April 14, 2010 Will something like the following work? Did you try it? I think using str_split will be fairly much easy for you Why would he want to use str_split()? Quote Link to comment https://forums.phpfreaks.com/topic/198513-isolate-9-consecutive-numbers-from-url/#findComment-1041658 Share on other sites More sharing options...
thumrith Posted April 14, 2010 Share Posted April 14, 2010 I think using str_split will be fairly much easy for you for example print_r(str_split("test")); will result Array ( [0] => t [1] => e [2] => s [3] => t ) my mistake wrong answer don't use this please Quote Link to comment https://forums.phpfreaks.com/topic/198513-isolate-9-consecutive-numbers-from-url/#findComment-1041662 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.