Re: Value of $var as a variable?

From: Date: Tue, 25 Feb 2003 02:00:52 +0000
Subject: Re: Value of $var as a variable?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-137019@lists.php.net to get a copy of this message
function getID($variable){ return $HTTP_GET_VARS[$variable]; } "Patrick Teague" <webdude@veslach.com> wrote in message news:001801c2dc6f$da4a05c0$fa01a8c0@EPSILON... > I know I've seen something about this (I can't remember whether yea or nay), > but I can't remember where I found it as at the time I was looking for > something else... and now that I'm looking for it I can't find it again. > Anyways, what I've done is store variable names that end up being passed as > part of various query strings in some variables similar to - > > $var_id = "id"; > $var_name = "name"; > > In the file that receives the information I'd like to know if there's a > faster way of finding out the value of the passed variables in the query > string than a function that explodes the query string & returns the value of > the requested variable. i.e. - > > function getID($variable) > { > // explode 'var=x' from query string > $id = explode( "&", $_SERVER["QUERY_STRING"] ); > > // search to find correct 'var=x' from query string > for( $i=0; $i<count($id); $i++ ) > { > // if $tag is found, extract value & assign to $value[] > if( $r = eregi( $variable."=([0-9])*", $id[$i], $regs ) ) > { > $value[] = $regs[1]; > } > } > return $value; > } > > > Patrick > >

« previous php.general (#137019) next »