NYCPHP Meetup

NYPHP.org

[nycphp-talk] Accessing non-existent array elements ok?

David Mintz david at davidmintz.org
Mon Aug 18 13:05:09 EDT 2008


On Mon, Aug 18, 2008 at 8:51 AM, Kenneth Downs <ken at secdat.com> wrote:

>
> function a(&$array, $key,$default='') {
>  if (isset($array[$key])) return $array[$key];
>  else return $default;
> }
>
> This allows you to code up simpler unconditional routines with code like:
>
> $value = a($myArray,$key,'AccetableDefault');



Does using an array reference &$array buy you anything in this instance?


-- 
David Mintz
http://davidmintz.org/

The subtle source is clear and bright
The tributary streams flow through the darkness
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20080818/743e65c0/attachment.html>


More information about the talk mailing list