|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-11-21 06:13 UTC] technophreak at gammae dot com
[2004-04-03 11:43 UTC] derick@php.net
[2004-08-25 10:28 UTC] leszek at dubiel dot pl
[2004-08-25 10:36 UTC] derick@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 01 02:00:01 2025 UTC |
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.