Re: [PHP] Variables Help

2004-05-14 Thread John Nichel
Ford, Mike [LSS] wrote:
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;
}
}


U, 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


Re: [PHP] Variables Help

2004-05-13 Thread John W. Holmes
From: Steve Douville [EMAIL PROTECTED]

 ?
 $a = yes;
 $b = no;
 ?

 Is there a variable that I can call that will return an array with any
 variables I have set? I'd want to call it and then parse and display
current
 values of, in this case, a and b. Hope that makes sense.

Like something that Returns an array of all defined variables??

http://us2.php.net/get_defined_vars

---John Holmes...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Variables Help

2004-05-13 Thread Adrian
$GLOBALS

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Variables Help

2004-05-13 Thread Richard Davey
Hello Steve,

Thursday, May 13, 2004, 6:19:07 PM, you wrote:

SD Is there a variable that I can call that will return an array with any
SD variables I have set? I'd want to call it and then parse and display current
SD values of, in this case, a and b. Hope that makes sense.

get_defined_vars();

-- 
Best regards,
 Richard Davey
 http://www.launchcode.co.uk / PHP Development Services
 http://www.phpcommunity.org/wiki/296.html / PHP Community

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Variables Help

2004-05-13 Thread John Nichel
John W. Holmes wrote:
From: Steve Douville [EMAIL PROTECTED]

?
$a = yes;
$b = no;
?
Is there a variable that I can call that will return an array with any
variables I have set? I'd want to call it and then parse and display
current

values of, in this case, a and b. Hope that makes sense.


Like something that Returns an array of all defined variables??

http://us2.php.net/get_defined_vars

---John Holmes...

Imagine that. ;)

--
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


Re: [PHP] Variables Help

2004-05-13 Thread Monty

 Is there a variable that I can call that will return an array with any
 variables I have set? I'd want to call it and then parse and display
 current
 values of, in this case, a and b. Hope that makes sense.
 
 Like something that Returns an array of all defined variables??
 
 http://us2.php.net/get_defined_vars
 
 ---John Holmes...

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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Variables Help

2004-05-13 Thread John Nichel
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;
	}
}

--
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


Re: [PHP] Variables Help

2004-05-13 Thread Jason Barnett
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
Why not just unset the variables you don't want in the list?

?php

$uservars = get_defined_vars();
unset ($uservars['_SERVER']);
unset ($uservars['_ENV']);
// etc.
?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Variables Help

2004-05-13 Thread John W. Holmes
From: Monty [EMAIL PROTECTED]
  Is there a variable that I can call that will return an array with any
  variables I have set? I'd want to call it and then parse and display
  current
  values of, in this case, a and b. Hope that makes sense.
 
  Like something that Returns an array of all defined variables??
 
  http://us2.php.net/get_defined_vars
 
  ---John Holmes...

 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.

?php
$starting_vars = get_defined_vars();

//bunch of PHP code...

$current_vars = get_defined_vars();

$user_defined_vars = array_diff($current_vars,$starting_vars);

...

---John Holmes...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Variables Help

2004-05-13 Thread John Nichel
John W. Holmes wrote:
?php
$starting_vars = get_defined_vars();
//bunch of PHP code...

$current_vars = get_defined_vars();

$user_defined_vars = array_diff($current_vars,$starting_vars);

...

---John Holmes...

This cat is skinned. :)

--
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


Re: [PHP] Variables Help

2004-05-13 Thread Jason Barnett
?php
$starting_vars = get_defined_vars();
//bunch of PHP code...

$current_vars = get_defined_vars();

$user_defined_vars = array_diff($current_vars,$starting_vars);

...

---John Holmes...
Oh I like that... wish I would have suggested that one!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Variables Help

2004-05-13 Thread Ford, Mike [LSS]
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;
   }
 }

U, 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: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Variables - Help

2002-12-16 Thread Kevin Stone
Difficult to tell exactly what your problem is but to disassociate a
varaible name to its place in memory you use, unset($varname);
-Kevin

- Original Message -
From: Beauford.2002 [EMAIL PROTECTED]
To: PHP General [EMAIL PROTECTED]
Sent: Tuesday, December 17, 2002 1:29 PM
Subject: [PHP] Variables - Help


 Hi,

 I have a webpage where users input information. This gets sent to a PHP
page
 to use this input. The first time the user inputs information it works
 correctly, but the second, third, forth, etc. times does not. It appears
the
 information from the first time is still stored in the variables I am
using
 in PHP. I have tried setting them all back to zero, but this does not
work.

 So how do I reset all the variables so that the new information is
contained
 in them when the user adds more information.

 TIA



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php