我有一个名为res_rooms的数组,使用print_r($res_rooms);
Array (
[0] => 80
[1] => 50
[2] => 80
[3] => 50
[4] => 80
[5] => 50
[6] => 80
[7] => 50
[8] => 80
[9] => 50
[10] => 80
[11] => 50
[12] => 80
[13] => 50
[14] => 80
[15] => 50
[16] => 80
[17] => 50
[18] => 80
[19] => 50
)
然后获得像这样的唯一值
$new_room = array_unique($res_rooms);
使用print_r($new_room );
打印值,但我什么都没得到,甚至没有恐怖
任何想法?提前致谢
答案 0 :(得分:1)
试试这段代码:
$arr = array(80,50,50,80);
echo "<br> Old Array : <hr> ";
print_r($arr);
array_unique($arr);
echo "<br> New Unique Array : <hr>";
print_r(array_unique($arr));
输出结果:
Old Array :
Array ( [0] => 80 [1] => 50 )
New Unique Array :
Array ( [0] => 80 [1] => 50 ) 1 2 3 4 ... 64 Next