virtuexru Posted February 12, 2009 Share Posted February 12, 2009 Quick question, I'm having a brainlapse right now. I want to take a url like this: http://anywhere.com/x/bw/bbbb/vid?lot=6874699 and extract just the number after "lot=" so I just need the numerical value. What's the most efficient way of doing this? Substr? (the number can be anywhere from 5-8 numerals). Quote Link to comment https://forums.phpfreaks.com/topic/144943-solved-how-to-cut-piece-of-string-p/ Share on other sites More sharing options...
premiso Posted February 12, 2009 Share Posted February 12, 2009 <?php $string = 'http://anywhere.com/x/bw/bbbb/vid?lot=6874699'; $string = explode('lot=', $string); $string = $string[1]; echo $string; ?> Quote Link to comment https://forums.phpfreaks.com/topic/144943-solved-how-to-cut-piece-of-string-p/#findComment-760578 Share on other sites More sharing options...
Philip Posted February 12, 2009 Share Posted February 12, 2009 Err, I misread the question. premiso is correct. If that is your page though, use $_GET['lot'] to get the number Quote Link to comment https://forums.phpfreaks.com/topic/144943-solved-how-to-cut-piece-of-string-p/#findComment-760589 Share on other sites More sharing options...
virtuexru Posted February 12, 2009 Author Share Posted February 12, 2009 <?php $string = 'http://anywhere.com/x/bw/bbbb/vid?lot=6874699'; $string = explode('lot=', $string); $string = $string[1]; echo $string; ?> You, are the man. Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/144943-solved-how-to-cut-piece-of-string-p/#findComment-760592 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.