I am sending dynamically created GET variables to a php page.
Usually I use:
$offset = $_GET['offset'];
$mortgage = $_GET['mortgage'];
to use the incoming GET variables.
My dynamically created incoming GET variables take the form:
t1=2,t2=4,t3=1,t4=7 etc.
Is there a way I can dynamically grab these for something like:
$t1 = $_GET['t1'] etc?
Dynamically handling GET variables?
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Dynamically handling GET variables?
It should be with ampersands for URL params:
mysite.com?t1=2&t2=4&t3=1&t4=7
mysite.com?t1=2&t2=4&t3=1&t4=7
(#10850)
Re: Dynamically handling GET variables?
Yes, I understand that. What I was fumbling to convey was that my variables follow a distinct sequence.arborint wrote:It should be with ampersands for URL params:
mysite.com?t1=2&t2=4&t3=1&t4=7
This is why I thought I may be able to 'automate' their capture.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Dynamically handling GET variables?
In this case where the number of elements is unknown you might want to use an array to be able to easily loop over the variables.PhpDog wrote:Yes, I understand that. What I was fumbling to convey was that my variables follow a distinct sequence.arborint wrote:It should be with ampersands for URL params:
mysite.com?t1=2&t2=4&t3=1&t4=7
This is why I thought I may be able to 'automate' their capture.
mysite.com?t[]=2&t[]=4&t[]=1&t[]=7
Code: Select all
foreach ($_GET['t'] as $key => $foo) {
echo $key .':'. $foo .'<br />';
}Re: Dynamically handling GET variables?
Many thanks to everyone who answered.