freelance84 Posted April 26, 2010 Share Posted April 26, 2010 I have managed to get a variable into the URL: ...nts.php?table=tester1 But how do I get the value of table out of it? Link to comment https://forums.phpfreaks.com/topic/199814-taking-values-from-url/ Share on other sites More sharing options...
aeroswat Posted April 26, 2010 Share Posted April 26, 2010 I have managed to get a variable into the URL: ...nts.php?table=tester1 But how do I get the value of table out of it? $_GET['table'] Link to comment https://forums.phpfreaks.com/topic/199814-taking-values-from-url/#findComment-1048812 Share on other sites More sharing options...
freelance84 Posted April 26, 2010 Author Share Posted April 26, 2010 thank you. I think i've been staring at my screen too long today, I tried that but it didn't work before, now it does Link to comment https://forums.phpfreaks.com/topic/199814-taking-values-from-url/#findComment-1048818 Share on other sites More sharing options...
aeroswat Posted April 26, 2010 Share Posted April 26, 2010 thank you. I think i've been staring at my screen too long today, I tried that but it didn't work before, now it does lol np Link to comment https://forums.phpfreaks.com/topic/199814-taking-values-from-url/#findComment-1048819 Share on other sites More sharing options...
trevorsg Posted April 26, 2010 Share Posted April 26, 2010 Here's another way: function get_params() { unset($_GET); //Frees up some memory $uri = explode('?', $_SERVER['REQUEST_URI']); $queryStr = $uri['1']; $vars = explode('&', $queryStr); $getVars = array(); foreach ($vars as $var) { $exp = explode('=', $var); $getVars[$exp[0]] = $exp[1]; } return $getVars; } And then you can use it to make any variable contain an array with your get variables! $some_var = get_params(); //your 'tester1' can be accessed by $some_var['table'] I know the above works because I read it on 4chan. Link to comment https://forums.phpfreaks.com/topic/199814-taking-values-from-url/#findComment-1048825 Share on other sites More sharing options...
aeroswat Posted April 26, 2010 Share Posted April 26, 2010 Here's another way: function get_params() { unset($_GET); //Frees up some memory $uri = explode('?', $_SERVER['REQUEST_URI']); $queryStr = $uri['1']; $vars = explode('&', $queryStr); $getVars = array(); foreach ($vars as $var) { $exp = explode('=', $var); $getVars[$exp[0]] = $exp[1]; } return $getVars; } And then you can use it to make any variable contain an array with your get variables! $some_var = get_params(); //your 'tester1' can be accessed by $some_var['table'] I know the above works because I read it on 4chan. Why would you ever do that? Link to comment https://forums.phpfreaks.com/topic/199814-taking-values-from-url/#findComment-1048846 Share on other sites More sharing options...
trevorsg Posted April 26, 2010 Share Posted April 26, 2010 Why would you ever do that? Sorry, just being humorous. Link to comment https://forums.phpfreaks.com/topic/199814-taking-values-from-url/#findComment-1048851 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.