Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Arrays with referenced variables
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:
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);
I've got another function which then uses that. Here's what I'm trying to do:
function escaper ($var1, $var2)
$escaped_array = escape_strings(array(&$var1, &$var2));
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...
"Let us smite the evil slime eating hordes who may befall us on our quest to be the ultimate programmers of the known universe!"
0 · ·