note 43842 added to function.array-walk-recursive
| From: | viper_sb at whydoesnthisworkyahoo dot com | Date: | Tue, 06 Jul 2004 03:26:52 +0000 |
| Subject: | note 43842 added to function.array-walk-recursive | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-72665@lists.php.net to get a copy of this message | ||
This function doesn't work as I expected it to. It WILL go though ALL members of an array, but
it WON'T return the key of an array member for example.
<?php
function test($value, $key)
{
print $key.'--'.$value."<br>\n";
}
$array = array(
'key1' => 'value1',
'value2',
'key3' => array(
'subkey1' => 'subvalue1'
)
);
array_walk_recursive($array, 'test');
?>
prints out
key1--value1
0--value2
subkey1--subvalue1
You will NOT be able to get key3 from within the callback function.
Also something else I might as well mention, if output buffering is on you get weird results i.e.
sometimes it'll output the values and other times it won't. This could just be something
specific to my system but maybe not.
----
Manual Page -- http://www.php.net/manual/en/function.array-walk-recursive.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+43842
Delete -- http://master.php.net/manage/user-notes.php?action=delete+43842&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+43842&report=yes
Search -- http://master.php.net/manage/user-notes.php