NYCPHP Meetup

NYPHP.org

[nycphp-talk] array_get_value?

Michael B Allen ioplex at gmail.com
Fri Sep 21 11:27:05 EDT 2007


Hey,

I find myself doing a lot of:

  if (isset($data['foo']))
      // use $data['foo']

Is there an existing array function that gets the array value or
returns a default value like:

  function array_get_value($arr, $key, $def) {
      return array_key_exists($arr, $key) ? $arr[$key] : $def;
  }

?

Mike



More information about the talk mailing list