[EMAIL PROTECTED] (Bryan McCloskey) wrote in
[EMAIL PROTECTED]:">news:[EMAIL PROTECTED]: 

> Hello all,
> 
> I'm trying to pass the $HTTP_POST_VARS array into a
> function to run some things like strip_tags, trim, and
> htmlspecialchars on all of the variables. If possible,
> I would like to pass this array by referrence, and
> have the function make changes to the actual array and
> not a copy. Accomplishing this is giving me fits,
> however. Can anyone help?
> 
> -bryan

This snippet from the manual tells how:

Making arguments be passed by reference
By default, function arguments are passed by value (so that if you change 
the value of the argument
within the function, it does not get changed outside of the function). If 
you wish to allow a function to
modify its arguments, you must pass them by reference.
If you want an argument to a function to always be passed by reference, you 
can prepend an ampersand
(&) to the argument name in the function definition:
function add_some_extra(&$string)
{
$string .= ’and something extra.’;
}
$str = ’This is a string, ’;
add_some_extra($str);
echo $str; // outputs ’This is a string, and something extra.’
If you wish to pass a variable by reference to a function which does not do 
this by default, you may
prepend an ampersand to the argument name in the function call:
function foo ($bar)
{
$bar .= ’ and something extra.’;
}
$str = ’This is a string, ’;
foo ($str);
echo $str; // outputs ’This is a string, ’
foo (&$str);
echo $str; // outputs ’This is a string, and something extra.’

-- 
David Robley
Temporary Kiwi!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to