Re: Yet another feature request
| From: | Patrick Mueller | Date: | Fri, 10 Nov 2006 15:22:35 +0000 |
| Subject: | Re: Yet another feature request | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-26470@lists.php.net to get a copy of this message | ||
Arnold Daniels wrote:
I see this is the time to do language feature request. So let me add another. I very often use something like: /$a = isset($x['abc']) ? //$x['abc'] : null; /This is to prevent an E_NOTICE from being thrown.It seems to me like adding a function: mixed array_get(mixed key, array search [, mixed default_value]) The implementation being: // constraint checking here if (array_key_exists($key,$search) return $search[$key]; return $default_value; would be the way to go. A functional way to do array access (I don't see another way to do this, actually), and also allow a default value if the specified key doesn't exit. Very similiar to the getProperty() method in Java's Properties class. -- Patrick_Mueller@us.ibm.com IBM PHP Community Architect, IBM Research Triangle Park