note 29476 deleted from function.explode by bjori

From: Date: Mon, 25 Sep 2006 08:14:37 +0000
Subject: note 29476 deleted from function.explode by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-117614@lists.php.net to get a copy of this message
Note Submitter: lennartg at web dot de ---- 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. <?php 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; } ?>

« previous php.notes (#117614) next »