note 43732 deleted from function.array-combine by tomsommer

From: Date: Sat, 03 Jul 2004 20:54:50 +0000
Subject: note 43732 deleted from function.array-combine by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-72487@lists.php.net to get a copy of this message
Note Submitter: c.g.j. geene ---- for older php versions I wrote a simple function who does the same... <?php $a = array('green', 'red', 'yellow'); $b = array('avocado', 'apple', 'banana'); if (!function_exists('array_combine')) { function array_combine($key_array, $value_array) { if (!is_array($key_array) || !is_array($value_array)) return false; $key_length = count($key_array); $value_length = count($value_array); if ($key_length != $value_length || $key_length == 0) return false; for ($i = 0, $combined = array(); $i < $key_length; $i++) { $combined[$key_array[$i]] = $value_array[$i]; } return $combined; } } $c = array_combine($a, $b); print_r($c); ?>

« previous php.notes (#72487) next »