note 52149 added to function.array-combine

From: Date: Fri, 22 Apr 2005 11:15:21 +0000
Subject: note 52149 added to function.array-combine
Groups: php.notes 
Request: Send a blank email to php-notes+get-88396@lists.php.net to get a copy of this message
For those of you want to use this function but have php version < 5.0 <?php if (!function_exists('array_combine')) { //{{{ array_combine /** * Creates an array by using one array for keys and another for its values * @param array $keys * @param array $values * @return Returns an array by using the values from the keys array as keys and the values from the values array as the corresponding values.<br />Returns FALSE if the number of elements for each array isn't equal or if the arrays are empty. * @author <dreptack [at] op [dot] pl> */ function array_combine($keys, $values) { if (!is_array($keys) || !is_array($values) || !$keys || !$values || count($keys) != count($values)) { return false; } reset($keys); reset($values); $retarr = array(); while (($keyarr = each($keys)) && ($valarr = each($values))) { $retarr[$keyarr['value']] = $valarr['value']; } return $retarr; } //}}} } //endif function_exists ?> Enjoy:-) ---- Manual Page -- http://www.php.net/manual/en/function.array-combine.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+52149 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52149&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52149&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52149&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52149&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52149&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+52149&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#88396) next »