Re: Passing an undetermined amount of arguments by reference
| From: | Jay Moore | Date: | Wed, 04 Feb 2009 20:33:52 +0000 |
| Subject: | Re: Passing an undetermined amount of arguments by reference | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-287638@lists.php.net to get a copy of this message | ||
Shawn McKenzie wrote:
Jay Moore wrote:What is the difference? Please excuse my naivety. :) JayJim Lucas wrote:I would try: $d = compact('a', 'b', 'c');Jay Moore wrote:Will that work properly? $a = "'hello'"; $b = "sup"; $c = "\\hola'"; $d = array($a, $b, $c); escape($id, $d); JayGreetings list. Say I have a function that escapes a string before being passed to MySQL like so: function escape($id, &$string) {Use an array as an alternate method of sending/returning data to the second argument. function escape($id, &$data) {$string }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.