note 52149 deleted from function.array-combine by aidan
| From: | aidan@php.net | Date: | Wed, 03 Aug 2005 03:06:18 +0000 |
| Subject: | note 52149 deleted from function.array-combine by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-92983@lists.php.net to get a copy of this message | ||
Note Submitter: dreptack at op dot pl
----
For those of you want to use this function but have php version < 5.0
<?php
if (!function_exists('array_combine')) {
//{{{ array_combine
/**
* Creates an array by using one array for keys and another for its values
* @param array $keys
* @param array $values
* @return Returns an array by using the values from the keys array as keys and the values from the
values array as the corresponding values.<br />Returns FALSE if the number of elements for
each array isn't equal or if the arrays are empty.
* @author <dreptack [at] op [dot] pl>
*/
function array_combine($keys, $values)
{
if (!is_array($keys) || !is_array($values) || !$keys || !$values || count($keys) !=
count($values)) {
return false;
}
reset($keys);
reset($values);
$retarr = array();
while (($keyarr = each($keys)) && ($valarr = each($values))) {
$retarr[$keyarr['value']] = $valarr['value'];
}
return $retarr;
} //}}}
} //endif function_exists
?>
Enjoy:-)