array_walk provides odd results
| From: | Waldo L. Jaquith | Date: | Mon, 13 Nov 2000 23:34:30 +0000 |
| Subject: | array_walk provides odd results | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-25057@lists.php.net to get a copy of this message | ||
Folks,
I'm trying to use array_walk to run a function on each element of an array.
But it just isn't working. Below is a simple little script -- I define a
function that runs AddSlashes, then I make a simple array, then array_walk
it, and finally echo the contents of the (theoretically) now-slash-escaped
array.
-------------------------------
function escape_quotes($data) {
$data = AddSlashes($data);
return $data;
}
$array[] = "''''";
$array[] = '""""';
array_walk($array, 'escape_quotes');
for ($i=0;$i<count($array);$i++) {
echo $array[$i];
}
-------------------------------
I've tried this on v4.0.0 and v4.03pl1 with the same results in each: no
slash-escaping of quotes. Having tried running other functions on the
content (trim, reversing the string, etc.), I believe that AddSlashes is not
a part of the problem.
Can anybody offer any suggestions as to what I'm doing wrong with
array_walk?
TIA,
Waldo
Waldo L. Jaquith
< waldo@munkandphyber.com >
< 804/979.2980 >
// Munk & Phyber, Inc.
// 110B Second Street NE
// Charlottesville, VA 22902