mjahkoh Posted October 26, 2007 Share Posted October 26, 2007 In coldfusion used to do it like <cfloop collection="#URL#" item="key"> <cfoutput>#key#</cfoutput> </cfloop> Its a bit tricky 4 me Emigrant Mjahkoh Quote Link to comment https://forums.phpfreaks.com/topic/74839-solved-loop-through-url-variables-as-a-structure/ Share on other sites More sharing options...
mjahkoh Posted October 26, 2007 Author Share Posted October 26, 2007 For instance if i had a url like http://www.mysite.com?a=1&b=2&c=3 how can i refer or loop through the variables a,b,c and treat them like a structure Quote Link to comment https://forums.phpfreaks.com/topic/74839-solved-loop-through-url-variables-as-a-structure/#findComment-378422 Share on other sites More sharing options...
LemonInflux Posted October 26, 2007 Share Posted October 26, 2007 on index.php (The home page) put this at the top: $a = $_GET['a']; $b = $_GET['b']; $c = $_GET['c']; For the rest of your script, a (1) will be $a, b (2) will be $b, and c (3) will be $c Quote Link to comment https://forums.phpfreaks.com/topic/74839-solved-loop-through-url-variables-as-a-structure/#findComment-378423 Share on other sites More sharing options...
mjahkoh Posted October 26, 2007 Author Share Posted October 26, 2007 Thanks Lemon, but everything has to be dynamic. am changing my code from Coldfusion.Am almost there. I got this and works but HTTP_GET_VARS is depracated. help me change it Begin Code while(list($key, $value) = each($HTTP_GET_VARS)) { echo "$key = $value(br)"; } End code Quote Link to comment https://forums.phpfreaks.com/topic/74839-solved-loop-through-url-variables-as-a-structure/#findComment-378425 Share on other sites More sharing options...
darkfreaks Posted October 26, 2007 Share Posted October 26, 2007 should use $_GET or $_REQUEST instead Quote Link to comment https://forums.phpfreaks.com/topic/74839-solved-loop-through-url-variables-as-a-structure/#findComment-378432 Share on other sites More sharing options...
GingerRobot Posted October 26, 2007 Share Posted October 26, 2007 Try: <?php foreach($_GET as $key => $value){ echo "$key = $value"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/74839-solved-loop-through-url-variables-as-a-structure/#findComment-378457 Share on other sites More sharing options...
mjahkoh Posted October 26, 2007 Author Share Posted October 26, 2007 Thanks GingerRobot. Will endevour 2 consume ginger every morning 2 sharpen them brains mjahkoh Quote Link to comment https://forums.phpfreaks.com/topic/74839-solved-loop-through-url-variables-as-a-structure/#findComment-378460 Share on other sites More sharing options...
GingerRobot Posted October 26, 2007 Share Posted October 26, 2007 Haha No problem. Quote Link to comment https://forums.phpfreaks.com/topic/74839-solved-loop-through-url-variables-as-a-structure/#findComment-378467 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.