note 29476 added to function.explode
| From: | lennartg at web dot de | Date: | Fri, 14 Feb 2003 13:52:19 +0000 |
| Subject: | note 29476 added to function.explode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-43937@lists.php.net to get a copy of this message | ||
Use this function to assign keys to the result array instead of numbered entries.
The $keys array must be a numeric array and must have same size entries in the $string.
function explodeKeys($separator, $string, $keys) {
$res = explode($separator, $string);
if (@is_array($res) && @is_array($keys)) {
$size = sizeof($res);
if ($size == sizeof($keys)) {
for ($i=0; $i < $size; $i++) {
$res[$keys[$i]] = $res[$i];
unset($res[$i]);
}
return $res;
}
}
return false;
}
--
http://www.php.net/manual/en/function.explode.php
http://master.php.net/manage/user-notes.php?action=edit+29476
http://master.php.net/manage/user-notes.php?action=delete+29476
http://master.php.net/manage/user-notes.php?action=reject+29476