Calling array_walk on the Nth dimension of a multidimensional array
| From: | Mark Lipscombe | Date: | Sun, 10 Dec 2000 04:19:42 +0000 |
| Subject: | Calling array_walk on the Nth dimension of a multidimensional array | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-29535@lists.php.net to get a copy of this message | ||
Hi,
I have the following code:
while (list ($key, $val) = each ($out))
array_walk ($val, remove_braces);
function remove_braces (&$item, $key) {
$item = substr ($item, 1, strlen($item) - 2);
print ($item);
}
Where $out is a multidimensional array as a result from preg_match_all(), in
the following structure:
(
[0] => Array
(
[0] => {BUTTON1:<p>[T]</p>|no tag}
)
)
I want to walk every single value of the array and run remove_braces over
it, but I can't work out how to modify the original array from within
array_walk because each() doesn't pass a reference to the array :(
With any luck, I'm missing something bleedingly obvious here and someone can
point that out, or a better/easier way of doing it.
Thanks :)
Mark
--
"Before man reaches the moon, your mail will be delivered within hours
from New York to California, from England to India, by guided missile. We
stand on the threshold of rocket mail."
- Arthur Summerfield, US Postmaster General, 23 June 1959