-1

My array contains duplicate values ...

i tried using array_unique function but its not working..

Code below...

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>";


} }

OUTPUT:

 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

1 Answer 1

0

Try using this way

in your query use distinct like this

SELECT DISTINCT column_name FROM table_name;

may be it will help

Sign up to request clarification or add additional context in comments.

2 Comments

query has got no duplicate values..i want to remove duplicates rom the array
may your while run two time check again

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.