note 105822 added to function.array-combine
| From: | DanLaManna at osu1 dot php dot net | Date: | Sun, 18 Sep 2011 03:12:05 +0000 |
| Subject: | note 105822 added to function.array-combine | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-183245@lists.php.net to get a copy of this message | ||
I needed a function that truncated extra values, and only went as far as keys without throwing a
warning as array_combine does.
function safeArrayCombine($keys, $values) {
$combinedArray = array();
for ($i=0, $keyCount = count($keys); $i < $keyCount; $i++) {
$combinedArray[$keys[$i]] = $values[$i];
}
return $combinedArray;
}
----
Server IP: 69.147.83.197
Probable Submitter: 67.246.26.139
----
Manual Page -- http://www.php.net/manual/en/function.array-combine.php
Edit -- https://master.php.net/note/edit/105822
Del: integrated -- https://master.php.net/note/delete/105822/integrated
Del: useless -- https://master.php.net/note/delete/105822/useless
Del: bad code -- https://master.php.net/note/delete/105822/bad+code
Del: spam -- https://master.php.net/note/delete/105822/spam
Del: non-english -- https://master.php.net/note/delete/105822/non-english
Del: in docs -- https://master.php.net/note/delete/105822/in+docs
Del: other reasons-- https://master.php.net/note/delete/105822
Reject -- https://master.php.net/note/reject/105822
Search -- https://master.php.net/manage/user-notes.php