e1seix Posted January 5, 2010 Share Posted January 5, 2010 Regex are not my strong points, so I'd appreciate all help. Say I have a url such as: www.mysite.com/?id=xyz&increment=01 If I'm searching plenty of rows in an sql expression, how would I separate the "id" which varies when the "increment" is also variable for each row. Quote Link to comment https://forums.phpfreaks.com/topic/187299-variable-url-regex/ Share on other sites More sharing options...
premiso Posted January 5, 2010 Share Posted January 5, 2010 Regex should not be needed for this, given that you are asking what I think you are you should be able to use $_GET: $id = isset($_GET['id'])?$_GET['id']:null; $increment = isset($_GET['increment'])?$_GET['increment']:null; If you have it inside of a string I would use parse_url: $text = "www.mysite.com/?id=xyz&increment=01"; $queryString = parse_url($text, PHP_URL_QUERY); list($id, $increment) = explode("&", $queryString); Not sure which you were after, but there it is. Quote Link to comment https://forums.phpfreaks.com/topic/187299-variable-url-regex/#findComment-989089 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.