note 49882 added to function.array-combine
| From: | hugh at e-access dot com dot au | Date: | Fri, 11 Feb 2005 04:51:44 +0000 |
| Subject: | note 49882 added to function.array-combine | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-84825@lists.php.net to get a copy of this message | ||
If you don't want to use, or can't use, the PEAR compatibility package, here is a PHP4
version of the function you can use in the meantime. Should more or less mirror the functionality of
the PHP5 version.
<?php
function array_combine($a1, $a2)
{
if(count($a1) != count($a2))
return false;
if(count($a1) <= 0)
return false;
$a1 = array_values($a1);
$a2 = array_values($a2);
$output = array();
for($i = 0; $i < count($a1); $i++)
{
$output[$a1[$i]] = $a2[$i];
}
return $output;
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.array-combine.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+49882
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49882&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49882&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49882&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49882&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49882&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+49882&report=yes
Search -- http://master.php.net/manage/user-notes.php