Shawn McKenzie wrote:
Jay Moore wrote:
Jim Lucas wrote:
Jay Moore wrote:
Greetings list.
Say I have a function that escapes a string before being passed to MySQL
like so:
function escape($id, &$string)
{
$string }
Use an array as an alternate method of sending/returning data to the
second argument.
function escape($id, &$data) {
if ( is_array($data) ) {
foreach ( $data AS $k => $v ) {
escape($id, $v);
$data[$k] = $v;
}
} else {
$data = mysql_real_escape_string($data, $id);
}
}
This would handle any number of nested arrays/datasets.
Hope it helps.
Will that work properly?
$a = "'hello'";
$b = "sup";
$c = "\\hola'";
$d = array($a, $b, $c);
escape($id, $d);
Jay
I would try: $d = compact('a', 'b', 'c');
What is the difference? Please excuse my naivety. :)
Jay
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php