note 53641 added to function.array-combine
| From: | dockeryz at gmail dot com | Date: | Wed, 08 Jun 2005 08:05:38 +0000 |
| Subject: | note 53641 added to function.array-combine | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-90096@lists.php.net to get a copy of this message | ||
For those people that have less values that keys for some reason.........this works well
It replaces what the values doesn't have with "" (nothing).
instead of null.
function array_combine($keys, $values) {
if(!is_array($keys)) return false;
if(!is_array($values)) return false;
$array = array();
//If there are more values than keys then
//the function will fail
if(count($keys) < count($values)) {
return false;
} else {
$count = count($keys);
for($i=0; $i<$count; $i++)
if(is_null($values))
$array[$keys[$i]] = "";
else
$array[$keys[$i]] = $values[$i];
}
return $array;
}
----
Manual Page -- http://www.php.net/manual/en/function.array-combine.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+53641
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+53641&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+53641&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+53641&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+53641&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+53641&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+53641&report=yes
Search -- http://master.php.net/manage/user-notes.php