Re: Variables Help
| From: | John Nichel | Date: | Fri, 14 May 2004 13:38:10 +0000 |
| Subject: | Re: Variables Help | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-186231@lists.php.net to get a copy of this message | ||
Ford, Mike [LSS] wrote:
On 13 May 2004 19:52, John Nichel wrote:That won't 'strip out' all the non-user defined vars...ones like HTTP_POST_VARS -- John C. Nichel KegWorks.com 716.856.9675 john@kegworks.comMonty wrote:Ummmm, or even, possibly, if no user variable names begin with _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. Montyforeach ( get_defined_vars() as $key => $val ) { if ( ! preg_match ( "/_POST|_GET|_COOKIE|_SERVER|_ENV|_FILES|_REQUEST|_SESSION/", $key ) ) { $user_defined[$key] = $val; } }if ($key{0}!='_')Cheers! Mike