note 43732 added to function.array-combine

From: Date: Thu, 01 Jul 2004 16:36:43 +0000
Subject: note 43732 added to function.array-combine
Groups: php.notes 
Request: Send a blank email to php-notes+get-72270@lists.php.net to get a copy of this message
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); ?> ---- Manual Page -- http://www.php.net/manual/en/function.array-combine.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+43732 Delete -- http://master.php.net/manage/user-notes.php?action=delete+43732&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+43732&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#72270) next »