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 Link to comment https://forums.phpfreaks.com/topic/76780-retrieve-string-from-url/ 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 Link to comment https://forums.phpfreaks.com/topic/76780-retrieve-string-from-url/#findComment-388729 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 Link to comment https://forums.phpfreaks.com/topic/76780-retrieve-string-from-url/#findComment-388730 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 Link to comment https://forums.phpfreaks.com/topic/76780-retrieve-string-from-url/#findComment-388735 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" ?> Link to comment https://forums.phpfreaks.com/topic/76780-retrieve-string-from-url/#findComment-388798 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.