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). 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; ?> 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 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! 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
Archived
This topic is now archived and is closed to further replies.