note 45376 added to function.array-walk
| From: | paul at heliosville dot com | Date: | Fri, 03 Sep 2004 19:13:47 +0000 |
| Subject: | note 45376 added to function.array-walk | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-75997@lists.php.net to get a copy of this message | ||
one rather important note that was lost in the Great PHP Doc Note Purge of '04 is that you can
call methods using array_walk(). Let's assume that we have a class named 'Search', in
which there is a method called 'convertKeywords'. Here's how you would call that
convertKeywords method from inside the class:
array_walk($keywords, array($this, 'convertKeywords'));
Notice that, instead of giving a string as the second argument, you give an array with two items:
the variable that holds the class (in this case, $this), and the method to call. Here's what it
would look like if you were to call convertKeywords from an already-instantiated class:
$search = new Search;
array_walk($keywords, array($search, 'convertKeywords'));
----
Manual Page -- http://www.php.net/manual/en/function.array-walk.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+45376
Delete -- http://master.php.net/manage/user-notes.php?action=delete+45376&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+45376&report=yes
Search -- http://master.php.net/manage/user-notes.php