Rumah >pembangunan bahagian belakang >tutorial php >取出数组中,前三小的三个单元,非连续索引数组
$arr =array( 11=>2530, 13=>8922, 26=>250, 77=>250, 88=>1230, 99=>12);
array(99=>12,26=>250,77=>250)
$arr =array( 11=>2530, 13=>8922, 26=>250, 77=>250, 88=>1230, 99=>12);asort($arr);print_r(array_slice($arr, 0, 3, true));
Array( [99] => 12 [77] => 250 [26] => 250)
$arr =array( 11=>2530, 13=>8922, 26=>250, 77=>250, 88=>1230, 99=>12);asort($arr);print_r(array_slice($arr, 0, 3, true));
Array( [99] => 12 [77] => 250 [26] => 250)