Re: how to use array_map() with a class callback function?
| From: | Peter James | Date: | Wed, 13 Aug 2003 06:40:21 +0000 |
| Subject: | Re: how to use array_map() with a class callback function? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-159401@lists.php.net to get a copy of this message | ||
array_map(array('Maker', 'sGetNameId'), array("1") )
Have a look at the callback type, here:
http://www.php.net/manual/en/language.pseudo-types.php
--
Peter James
Editor-in-Chief, php|architect Magazine
petej@phparch.com
php|architect
The Magazine for PHP Professionals
http://www.phparch.com
----- Original Message -----
From: "Jean-Christian IMbeault" <jc@mega-bucks.co.jp>
To: <php-general@lists.php.net>
Sent: Wednesday, August 13, 2003 12:33 AM
Subject: [PHP] how to use array_map() with a class callback function?
> I'd like to use array map with the callback function being a static
> function in a class. How can I do that?
>
> I have tried:
>
> class Maker {
> function sGetNameId($a) {
> return 1;
> }
> }
>
> array_map("Maker::sGetNameId", array("1") )
>
> But I get this error:
>
> array_map(): The first argument, 'Maker::sGetNameId', should be either
> NULL or a valid callback
>
> Is it possible to use class functions as callback functions?
>
> Thanks,
>
> Jean-Christian Imbeault
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>