note 120107 deleted from function.array-walk-recursive by crell
| From: | crell@php.net | Date: | Tue, 12 Apr 2022 01:07:21 +0000 |
| Subject: | note 120107 deleted from function.array-walk-recursive by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-218198@lists.php.net to get a copy of this message | ||
Note Submitter: KH
----
Example for the use of $userdata:
$userdata is the third parameter of the callback function.
The first parameter is $item, the second is $key, and the third one is $userdata.
<?php
$sweet = array('a' => 'Apfel', 'b' => 'Banane');
$fruits = array('süÃ' => $sweet, 'sauer' => 'Zitrone');
function test_print($item, $key, $info)
{
echo "$key beinhaltet $item $info\n";
}
array_walk_recursive($fruits, 'test_print', ' ... Bio');
?>
generates
a beinhaltet Apfel ... Bio
b beinhaltet Banane ... Bio
sauer beinhaltet Zitrone ... Bio