feras80 Posted November 10, 2007 Share Posted November 10, 2007 i have the following URL : www.mysite.com/Rates/USA/1/China/2 i wana extract the two countries from this URL ( USA and China) can u guys help me? am new in php N.B: this URL is rewrited using mode rewrite. thank you Feras Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted November 10, 2007 Share Posted November 10, 2007 do print_r($_GET) and see what you get Quote Link to comment Share on other sites More sharing options...
feras80 Posted November 10, 2007 Author Share Posted November 10, 2007 do print_r($_GET) and see what you get i got the actual URL ( [id_country_from] => 182 [id_country_to] => 182 ) i need to get the rewrited URL strings Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted November 10, 2007 Share Posted November 10, 2007 i'll assume 181 = USA and 182 = china so some how you have to retrieve that array and then just say $country_to = $array[$_GET[id_country_to]]; $country_from = $array[$_GET[id_country_from]]; That array exist somewhere on your server Quote Link to comment Share on other sites More sharing options...
thebadbad Posted November 10, 2007 Share Posted November 10, 2007 <?php $url = $_SERVER['REQUEST_URI']; //will set $url to "/Rates/USA/1/China/2" $bits = explode('/', $url); // $bits[1] contains "Rates" // $bits[2] contains "USA" // $bits[3] contains "1" // $bits[4] contains "China" // $bits[5] contains "2" ?> Quote Link to comment 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.