Ask a Question related to PHP Bugs, Design and Development.
-
t dot kloppenburg at billiton dot de #1
#40792 [NEW]: Wish: Function array_get(&$mixed, $key, $defaultvalue)
From: t dot kloppenburg at billiton dot de
Operating system: Linux
PHP version: 5.2.1
PHP Bug Type: Feature/Change Request
Bug description: Wish: Function array_get(&$mixed, $key, $defaultvalue)
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.
--
Edit bug report at [url]http://bugs.php.net/?id=40792&edit=1[/url]
--
Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=40792&r=trysnapshot44[/url]
Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=40792&r=trysnapshot52[/url]
Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=40792&r=trysnapshot60[/url]
Fixed in CVS: [url]http://bugs.php.net/fix.php?id=40792&r=fixedcvs[/url]
Fixed in release: [url]http://bugs.php.net/fix.php?id=40792&r=alreadyfixed[/url]
Need backtrace: [url]http://bugs.php.net/fix.php?id=40792&r=needtrace[/url]
Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=40792&r=needscript[/url]
Try newer version: [url]http://bugs.php.net/fix.php?id=40792&r=oldversion[/url]
Not developer issue: [url]http://bugs.php.net/fix.php?id=40792&r=support[/url]
Expected behavior: [url]http://bugs.php.net/fix.php?id=40792&r=notwrong[/url]
Not enough info: [url]http://bugs.php.net/fix.php?id=40792&r=notenoughinfo[/url]
Submitted twice: [url]http://bugs.php.net/fix.php?id=40792&r=submittedtwice[/url]
register_globals: [url]http://bugs.php.net/fix.php?id=40792&r=globals[/url]
PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=40792&r=php3[/url]
Daylight Savings: [url]http://bugs.php.net/fix.php?id=40792&r=dst[/url]
IIS Stability: [url]http://bugs.php.net/fix.php?id=40792&r=isapi[/url]
Install GNU Sed: [url]http://bugs.php.net/fix.php?id=40792&r=gnused[/url]
Floating point limitations: [url]http://bugs.php.net/fix.php?id=40792&r=float[/url]
No Zend Extensions: [url]http://bugs.php.net/fix.php?id=40792&r=nozend[/url]
MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=40792&r=mysqlcfg[/url]
t dot kloppenburg at billiton dot de Guest
-
DefaultValue attribute doesn't get set in a composite custom control
I have a simple composite control with the following attributes: public string NameLabelText { get { EnsureChildControls(); return... -
DefaultValue for Public Property of ASP.NET 2.0 UserControl not appearing in Properties Window
First, I'm using Visual Web Developer 2005 Express Edition, which I hope is exactly the same as Visual Studio 2005 minus a bunch of useful... -
DefaultValue not working (string)
My defaultvalue attribute is not working. If i drop this control from thetoolbox onto my page the properties are empty. They keep being empty if i... -
mixed up sprites
I'm having a rather strange / frustrating navigation issue. Here's the scenario: On one frame I have a full-screen flash sprite. A few frames down... -
ADMINISTRATOR MIXED UP
I think you renamed your Administrator account to "Rick". Enter %userprofile% to see what profile your "Rick" account is using. If it is... -
t dot kloppenburg at billiton dot de #2
#40792 [Opn]: Wish: Function array_get(&$mixed, $key, $defaultvalue)
ID: 40792
User updated by: t dot kloppenburg at billiton dot de
Reported By: t dot kloppenburg at billiton dot de
Status: Open
Bug Type: Feature/Change Request
Operating System: Linux
PHP Version: 5.2.1
New Comment:
ok, I code in PHP all this years and I miss it in PHP :)
Previous Comments:
------------------------------------------------------------------------
[2007-03-13 11:23:03] t dot kloppenburg at billiton dot de
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.
------------------------------------------------------------------------
--
Edit this bug report at [url]http://bugs.php.net/?id=40792&edit=1[/url]
t dot kloppenburg at billiton dot de Guest



Reply With Quote

