note 84193 modified in function.array-walk by thiago
| From: | thiago@php.net | Date: | Tue, 22 Jul 2008 16:57:40 +0000 |
| Subject: | note 84193 modified in function.array-walk by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-142507@lists.php.net to get a copy of this message | ||
to array_walk with a function defined in a class, try this:
<?php
// An example callback method
class MyClass {
static function myCallbackMethod($data) {
return $data.$data;
}
}
$my_array = array('one','two','three');
// Static class method cal
array_walk($my_array,array('MyClass', 'myCallbackMethod'));
?>
returns array('oneone','twotwo','threethree');
code from: http://uk.php.net/manual/en/language.pseudo-types.php
thought it would be useful here.
--was--
to array_walk with a function defined in a class, try this:
<?
// An example callback method
class MyClass {
static function myCallbackMethod($data) {
return $data.$data;
}
}
$my_array = array('one','two','three');
// Static class method cal
array_walk($my_array,array('MyClass', 'myCallbackMethod'));
?>
returns array('oneone','twotwo','threethree');
code from: http://uk.php.net/manual/en/language.pseudo-types.php
thought it would be useful here.
http://php.net/manual/en/function.array-walk.php