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
That won't 'strip out' all the non-user defined vars...ones like HTTP_POST_VARS
-- John C. Nichel KegWorks.com 716.856.9675 [EMAIL PROTECTED]
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php