Hello, I'm working via modrewrite to pass this: http://www.test.com/profile/123_text.html http://www.test.com/profile/text.html It goes toe prfile.php?id=123_text or prfile.php?id=text Now in my prfile script i want something that grabs out the 123 out of the id till the _ char. When there is no 123_ or 454_, ... then it must let the id like it is. Can someone helps me in here ? Ow and i'm sorry for my very bad english Cheers Kris
<? $url = "http://www.test.com/profile/123_text.html"; preg_match("/[0-9]+_/", $url, $matches); echo "The number you're looking for is stored in . <br>" . '$matches[0]' . " : " . $matches[0]; PHP:
I hope that you realize that you need to use that regex in your htaccess file for the mod-rewrite to work properly. you dont parse the url in the script, you parse it in htaccess and redirect it to the correct page, which then can do additional parsing of the formatted url. ;-) good luck.