So then can anyone tell me why its working so far? ;)

I am trying out every single function in this page in hopes to catch something, but so far I don't see any breakage - I can see there are a few ways to skin this cat.. the original code I posted DOES work.. I still may be blind to any future breakings.. that's why I posted it. Unfortunately, I'm getting responses saying that this code won't work at all - when it does.. :-/

Mike Ford wrote:
-----Original Message-----
From: Kevin Stone [mailto:kevin@;]
Sent: 06 November 2002 18:50
Subject: Re: [PHP] Code Advice

All I have to go by is what I see. The method was this..

$get_allow = array('foo', 'bar', 'add', 'takeovertheworld');

while (list($key,$val)=each($get_allow))
if (isset($_GET[$key]))
$$key = $val;

The array $get_allow has numerical indicies. Looping through that in the
method described is going to set an integer to $key. So your first error is
going to be that $_GET[0] is Undefined. Second error is going to be $$key
is an invalid variable name.

Mea culpa -- you're quite right, and I should read more carefully! (Well, it is 7pm and going home time....)

This should, of course, be done like this:

$get_allow = array(......);

foreach ($get_allow as $key):
if (isset($_GET($key)):
$$key = $_GET[$key];



Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to