Re: array_walk, or array_map, or foreach?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2006-10-20 at 16:04 +0900, Dave M G wrote:
> PHP List,
> 
> I took a snippet of code right off the php.net site to use trim on all 
> the elements of an array.
> 
> Theoretically, it should test if the element in an array is in turn 
> another array, and break it down to the next level until it gets to a 
> string it can use trim on.
> 
> This is the code:
> 
> public static function trimArray($array)
> {
> if (is_array($array))
> {
> array_walk($array, "trimArray");

I'm too lazy too look, but usually when using a class method as a
handler for PHP callback functions you pass the method as follows:

    array_walk( $array, array( 'ClassName', 'trimArray' ) );

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux