Arrays with referenced variables - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Arrays with referenced variables

ITAITA Posts: 463Member
Hi, I've created a function which'll escape an array of strings for me, ready for inserting into a mysql_db. Here's the function which escapes them:

[code]
function escape_strings($strings = array())
{
# returns an array of strings which have been escaped with mysql_escape_string
$escaped_strings = array();
foreach ($strings as $string)
{
$escaped_strings[] = mysql_escape_string($string);
}
return $escaped_strings;
}
[/code]

I've got another function which then uses that. Here's what I'm trying to do:

[code]
function escaper ($var1, $var2)
{
$escaped_array = escape_strings(array(&$var1, &$var2));
}
[/code]

Firstly, is the above valid syntax (with the '&'). Second, will this modify the original $var1 and $var2, ie will $var1 and $var2 be escaped for me? If not, how would I go about doing this?

I've made escape_strings return the escaped array, because it might be useful at some point...

Please help.

Many thanks.

Isaac
"Let us smite the evil slime eating hordes who may befall us on our quest to be the ultimate programmers of the known universe!"
Sign In or Register to comment.