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 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 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 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 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 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"; } ?> 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 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. 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
Archived
This topic is now archived and is closed to further replies.