note 108996 added to function.array-walk
| From: | selimacar at hotmail dot com | Date: | Mon, 11 Jun 2012 13:34:51 +0000 |
| Subject: | note 108996 added to function.array-walk | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-188526@lists.php.net to get a copy of this message | ||
####### I intuitively tried to use array_walk function with PHP built-in function
"abs($var)" but it did not work and got some warning message
$values = array(-5,2,3,-8,4,-1,0);
array_walk($values, "abs");
=> Warning: abs() expects exactly 1 parameter, 2 given in ...
###### Then I wrote this function :
function myAbs(&$val){
$val = abs($val);
}
array_walk($values, "myAbs");
##### It works!
----
Server IP: 158.255.214.58
Probable Submitter: 217.5.227.147
----
Manual Page -- http://www.php.net/manual/en/function.array-walk.php
Edit -- https://master.php.net/note/edit/108996
Del: integrated -- https://master.php.net/note/delete/108996/integrated
Del: useless -- https://master.php.net/note/delete/108996/useless
Del: bad code -- https://master.php.net/note/delete/108996/bad+code
Del: spam -- https://master.php.net/note/delete/108996/spam
Del: non-english -- https://master.php.net/note/delete/108996/non-english
Del: in docs -- https://master.php.net/note/delete/108996/in+docs
Del: other reasons-- https://master.php.net/note/delete/108996
Reject -- https://master.php.net/note/reject/108996
Search -- https://master.php.net/manage/user-notes.php