in a very tight loop I need to access tenthousands of values in an array containing millions of elements. The key can be undefinied: In that case it shall be legal to return
There are two typical approaches to this.
Here is how to perform the first and as little code as possible.
$data = array_merge(array($key=>false),$data);
return $data[$key];
Here is how to perform the second.
return isset($data[$key]) ? $data[$key] : false;