php-groups.com | Post Question | Search | About | Groups | Contact | Register | Login


New in This Group

Notes Status, 23322 total
3/28/2010 12:36:22 PM

Notes Status, 22746 total
12/13/2009 12:34:00 PM

note 94737 added to function.explode
11/21/2009 2:49:15 AM

note 94736 added to function.include
11/21/2009 12:54:03 AM

note 94735 added to book.curl
11/20/2009 11:31:12 PM

note 94734 added to language.oop5.abstract
11/20/2009 10:16:10 PM

note 94733 added to function.addslashes
11/20/2009 9:04:30 PM

note 94732 added to function.readdir
11/20/2009 6:45:32 PM

note 94731 added to streamwrapper.construct
11/20/2009 6:27:10 PM

note 94730 added to faq.databases
11/20/2009 5:24:17 PM

note 95437 added to function.array-walk Reply

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





Reply:
| or Email(not shown): Name: | Register | Login

Alert me when someone responds to this posting.











Newest Articles

note 97095 added to soapclient.soapclient
4/1/2010 5:58:19 AM

note 97094 added to function.sqlite-changes
4/1/2010 5:06:46 AM

note 97093 added to function.sqlite-changes
4/1/2010 5:06:21 AM

note 97092 added to ref.xmlrpc
4/1/2010 4:52:18 AM

note 97091 added to function.var-export
4/1/2010 3:32:03 AM