在PHP中将简单数组转换为关联数组的最快方法是什么,以便可以在isset($array[$value])?中检查值?
isset($array[$value])
这是进行以下转换的最快方式:
$array = array(1, 2, 3, 4, 5); $assoc = array(); foreach ($array as $i => $value) { $assoc[$value] = 1; }
php arrays dictionary associative
arrays ×1
associative ×1
dictionary ×1
php ×1