note 53641 deleted from function.array-combine by aidan

From: Date: Wed, 03 Aug 2005 03:05:34 +0000
Subject: note 53641 deleted from function.array-combine by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-92980@lists.php.net to get a copy of this message
Note Submitter: dockeryz at gmail dot com ---- 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; }

« previous php.notes (#92980) next »