RE: [PHP] Variables Help
| From: | Ford, Mike [LSS] | Date: | Thu, 13 May 2004 18:55:54 +0000 |
| Subject: | RE: [PHP] Variables Help | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-186155@lists.php.net to get a copy of this message | ||
On 13 May 2004 19:52, John Nichel wrote:
> Monty wrote:
> > Is there any way to get JUST the user-defined variables in PHP?
> > Problem with get_defined_vars() is that it contains everything,
> > including server and environment vars, and there's no easy way to
> > keep just the user-defined vars part of the array created by
> > get_defined_vars.
> >
> > Monty
> >
>
> foreach ( get_defined_vars() as $key => $val ) {
> if ( ! preg_match (
> "/_POST|_GET|_COOKIE|_SERVER|_ENV|_FILES|_REQUEST|_SESSION/", $key )
> ) { $user_defined[$key] = $val;
> }
> }
Ummmm, or even, possibly, if no user variable names begin with _
if ($key{0}!='_')
Cheers!
Mike
---------------------------------------------------------------------
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
Email: m.ford@leedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211