note 85000 modified in function.array-combine by felipe

From: Date: Mon, 11 Aug 2008 14:37:13 +0000
Subject: note 85000 modified in function.array-combine by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-143368@lists.php.net to get a copy of this message
This may be obvious, but I don't see anything about it on the manual page, so a friendly warning... The array you are using as keys must have all unique values. If not, array elements get dropped. <?php $arr_notUnique = array('one' , 'one' , 'two'); $arr_b = array('red' , 'green' , 'blue'); $arr_combo = array_combine($arr_notUnique, $arr_b); ?> Results: Array ( [one] => green [two] => blue ) NOT: Array ( [one] => red [one] => green [two] => blue ) --was-- This may be obvious, but I don't see anything about it on the manual page, so a friendly warning... The array you are using as keys must have all unique values. If not, array elements get dropped. $arr_notUnique = array('one' , 'one' , 'two'); $arr_b = array('red' , 'green' , 'blue'); $arr_combo = array_combine($arr_notUnique, $arr_b); Results: Array ( [one] => green [two] => blue ) NOT: Array ( [one] => red [one] => green [two] => blue ) http://php.net/manual/en/function.array-combine.php

« previous php.notes (#143368) next »