我有一个名为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 );
打印值,但我什么也得不到,甚至连AROR 都得不到
有什么想法吗?提前感谢
试试这个代码:
$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