Req #64818 [NEW]: array_get
| From: | mario dot dweller at seznam dot cz | Date: | Sat, 11 May 2013 17:07:24 +0000 |
| Subject: | Req #64818 [NEW]: array_get | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-178892@lists.php.net to get a copy of this message | ||
From: mario dot dweller at seznam dot cz
Operating system:
PHP version: Irrelevant
Package: Arrays related
Bug Type: Feature/Change Request
Bug description:array_get
Description:
------------
What about to create a new array function array_get? When we have a
function like array_column...
function array_get(array $array, $key, $default = null)
Something like this.
http://api.nette.org/2.0/source-Utils.Arrays.php.html#36-53
Ofc i can use that Arrays::get method or i can create my own
function/static method. But it has a performance overhead for quite a
common thing which should be as fast as it's possible.
I hate typing this.
isset($array['key1']['key2']) ? $array['key1']['key2'] :
null;
This looks better.
array_get($array, ['key1', 'key2'], null)
or just
array_get($array, 'key')
--
Edit bug report at https://bugs.php.net/bug.php?id=64818&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64818&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64818&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64818&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=64818&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=64818&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=64818&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=64818&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=64818&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=64818&r=support
Expected behavior: https://bugs.php.net/fix.php?id=64818&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=64818&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=64818&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=64818&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64818&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=64818&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=64818&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=64818&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64818&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=64818&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=64818&r=mysqlcfg