note 14333 added to ref.array.php
| From: | e at NOSPAM dot arix dot com | Date: | Fri, 27 Jul 2001 01:01:23 +0000 |
| Subject: | note 14333 added to ref.array.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-15888@lists.php.net to get a copy of this message | ||
this function makes an indexed array into a hashed array:
function arr2hash($a) {
for ($i = 0; $i < count($a); $i += 2) $ret[$a[$i]] = $a[$i+1];
return $ret;
}
$x = array("one", "two", "three", "four", "five",
"six");
$y = arr2hash($x);
echo $y["one"];
http://www.php.net/manual/en/ref.array.php