|
||||||||||
|
New in This Group Notes Status, 23322 total3/28/2010 12:36:22 PM Notes Status, 22746 total12/13/2009 12:34:00 PM note 94737 added to function.explode11/21/2009 2:49:15 AM note 94736 added to function.include11/21/2009 12:54:03 AM note 94735 added to book.curl11/20/2009 11:31:12 PM note 94734 added to language.oop5.abstract11/20/2009 10:16:10 PM note 94733 added to function.addslashes11/20/2009 9:04:30 PM note 94732 added to function.readdir11/20/2009 6:45:32 PM note 94731 added to streamwrapper.construct11/20/2009 6:27:10 PM note 94730 added to faq.databases11/20/2009 5:24:17 PM |
note 95437 added to function.array-walk
|
|||||||||
| Group: php.notes |
Subscribe
|
Posted:1/3/2010 3:17:15 PM | Replies:0 | Views:41 | Items(0) |
|
You can use lambda function as a second parameter:
<?php array_walk($myArray, function(&$value, $key){ // if you want to change array values then "&" before the $value is mandatory. }); ?> Example (multiply positive values by two): <?php $myArray = array(1, 2, 3, 4, 5); array_walk($myArray, function(&$value, $index){ if ($value > 0) $value *= 2; }); ?> ---- Server IP: 93.93.89.253 Probable Submitter: 194.220.83.177 ---- Manual Page -- http://www.php.net/manual/en/function.array-walk.php Edit -- https://master.php.net/note/edit/95437 Del: integrated -- https://master.php.net/note/delete/95437/integrated Del: useless -- https://master.php.net/note/delete/95437/useless Del: bad code -- https://master.php.net/note/delete/95437/bad+code Del: spam -- https://master.php.net/note/delete/95437/spam Del: non-english -- https://master.php.net/note/delete/95437/non-english Del: in docs -- https://master.php.net/note/delete/95437/in+docs Del: other reasons-- https://master.php.net/note/delete/95437 Reject -- https://master.php.net/note/reject/95437 Search -- https://master.php.net/manage/user-notes.php |
arekand...@yandex.ru 1/3/2010 3:17:15 PM |
note 97095 added to soapclient.soapclient
note 97094 added to function.sqlite-changes
note 97093 added to function.sqlite-changes
note 97092 added to ref.xmlrpc
note 97091 added to function.var-export