我的数组包含重复值...
我尝试使用array_unique函数,但它不起作用..
以下代码......
while($ rowTable = mysql_fetch_array($ resultTable)){
$selQuery = "SELECT * FROM dump_hotelamenities WHERE HotelCode='$rowTable[HotelCode]' LIMIT 5"; $resultQuery = mysql_query($selQuery); while($row=mysql_fetch_array($resultQuery)) { echo "<br> Hotel Code : " .$row['HotelCode']; //$info = array(); $info=(str_replace('YES','',$row['PAmenities'])); $info_new=array(); $info_new =array_unique(explode(';',$info)); echo "<br> Hotel Features : " ; print_r ($info_new); echo "<hr>"; } }
输出:
Array ( [0] => Small pets allowed under 5 kg [1] => Small pets allowed under 5 kg [2] => Large pets allowed over 5 kg [3] => Large pets allowed over 5 kg [4] => Wheelchair-accessible [5] => Wheelchair-accessible [6] => Car park [7] => Car park [8] => Garage [9] => Garage [10] => Mobile phone coverage [11] => Wired Internet [12] => Wi-fi [13] => Transfer service [14] => Secure parking [15] => Room service [16] => Laundry service [17] => Hotel safe [18] => Cloakroom [19] => Lift access [20] => Newspaper stand [21] => Supermarket [22] => Bicycle storage [23] => Sun terrace [24] => Gym [25] => Newspapers [26] => Restaurant [27] => Non-smoking area [28] => Photocopier [29] => Sun loungers [30] => Children& [31] => apos [32] => s play area [33] => TV lounge [34] => Sauna [35] => Massage [36] => Spa treatments [37] => Year of construction - 2008 [38] => Number of floors main building - 10 [39] => Apartments - 25 [40] => Studios - 1 [41] => Connecting rooms [42] => Connecting rooms [43] => Apartment complex [44] => Nearest Bus / Metro Stop - 25000 m [45] => Ski slopes - 2000 m )
答案 0 :(得分:0)
尝试使用这种方式
您的查询中的使用与此类似的
{{1}}
可能会有所帮助