ID: 26347
Comment by: leszek at dubiel dot pl
Reported By: technophreak at gammae dot com
Status: Wont fix
Bug Type: Feature/Change Request
Operating System: all
PHP Version: 4.3.2
New Comment:
Yes -- we can use these two lines of code, but I thought php was build
to be simple -- why does it have so many other functions? I think this
should be opened.
Previous Comments:
------------------------------------------------------------------------
[2004-04-03 11:43:50] [EMAIL PROTECTED]
You can use those two lines of code just fine. Marking this "won't
fix".
regards,
Derick
------------------------------------------------------------------------
[2003-11-21 06:13:02] technophreak at gammae dot com
sorry for the typo, I meant SUCH, not SUC* ...
------------------------------------------------------------------------
[2003-11-21 06:11:09] technophreak at gammae dot com
Description:
------------
There should be a function used to simply return element [n] of an
array. This will allow to return the value of an array by simply
specifying the key or element to be returned. list() or any other
function can do this.
if a such function alredy exist please let me know. I didnt find it.
Reproduce code:
---------------
Sample code of what function should do.
function array_element($array array,$element mixed){
return $array[$element];
}
here is an example of why that would be useful.
If i dont want to write two lines to get a hostname from a url.
$myhost = array_element(parse_url($someurl),"host");
INSTEAD OF
$host_info = parse_url($someurl);
$myhost = $host_info["host"];
Also.. there are many things that the list() function cannot do ... an
array_element() function would be very useful in any situation where
the array would be the result of another function ..
There are numerous examples where I would have used that and I am sure
that a lot of people would be looking for suck feature.
Same idea for an array_put() function but array_merge() does the same.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=26347&edit=1