Reply-Via-Newsgroup wrote:
Folks,
I have a multi-dimensional array that I read from my mysql database. I'd
like to run strip slashes against each element and I'm pretty sure that
array_walk() (or array_map) is likely to solve my problem - But I've not got
the foggiest
on how to use it - I've taken a look in the php.chm manual supplied from
php.net and I don't seem to have had any success so far - Can anyone suggest
how I could stripslashes to every element without having to build my own
function?
(I don't want to use my own function when one already exists in PHP - In
part, because its more performance effective to use a precompiled function).
all helps.. via the newsgroup... is much apprecaited,
thanks
randelld
Try the following (untested) function:
function stripSlashes(&$var) {
if (is_string($var)) {
$var = stripslashes($var);
} else { // assume it is an array
foreach($var as $key => $value) {
stripSlashes($var[$key]);
}
}
}
--
Amir Khawaja.
----------------------------------
Rules are written for those who lack the ability to truly reason, But
for those who can, the rules become nothing more than guidelines, And
live their lives governed not by rules but by reason.
- James McGuigan