On Wed, 2007-09-12 at 13:53 -0400, Andrew Shearer wrote:
>
> 
> Here is the patch and unit test file for array_get():
> 
> http://ashearer.com/software/array_get/2007-09-10-php6/array_get.diff
> http://ashearer.com/software/array_get/2007-09-10-php6/array_get.phpt
> 
> 
> And here is the backward compatibility function:
> 
> if (!function_exists('array_get')) {
>     function array_get($arr, $key, $default = false) {
>         if (array_key_exists($key, $arr)) {
>             return $arr[$key];
>         }
>         else {
>             return $default;
>         }
>     }
> }

IMHO the default value for $default should be null. That way it has the
same return value as using an undefined index on an array.

Comments?

Cheers,
Rob.
-- 
...........................................................
SwarmBuy.com - http://www.swarmbuy.com

    Leveraging the buying power of the masses!
...........................................................

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to