|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-03-13 14:35 UTC] t dot kloppenburg at billiton dot de
[2007-09-11 16:50 UTC] andrew at ashearer dot com
[2010-10-13 10:47 UTC] lethalman88 at gmail dot com
[2015-01-09 00:43 UTC] ajf@php.net
-Status: Open
+Status: Closed
-Package: Feature/Change Request
+Package: *General Issues
-Assigned To:
+Assigned To: ajf
[2015-01-09 00:43 UTC] ajf@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 01 16:00:02 2025 UTC |
Description: ------------ I miss a function or ArrayObject method to get an element of an array, or alternativly a default value if the key is not set in the array. In python: mydict = {'key1' : 'value1'} val = mydict.get('otherkey', 'defaultvalue') -> 'defaultvalue' This is very handy when dealing with arrays. I'ld be happy to see this in PHP4 and PHP5. It could look like this: $cfg = array('version' => '1.2v', 'othercfg' => 'otherval'); $tmppath = array_get( $cfg, 'tmppath', '/tmp' ); -> '/tmp' or with ArrayObject as: $tmppath = $arrobj->get( 'tmppath', '/tmp' ); -> '/tmp' (if not set in the array) I code in Python since 6 or 7 years, and I really miss this function in everyday-use.