0

I have an array and i want to show all values but dont wanna show the double values. I dont want to delete the double values with the array_unique() function. Can someone show me how to do it.

    foreach ($comTemperatures1 as $value) {
    //$y = "0";

    //$y++;
    $class = "TC " . $value;
    //if ($thermoStatus[$y] == '0' ) {
    echo"<td class=\"$class\" id=\"$class\">" . $temperatures[$value] . "</td>";
    //} else if ($thermoStatus[$y] == '6' ) {  
    //}
}

$comTemperatures1 = array('3' ,'3','4', '4');

It't not a duplicate question because i don't want to delete the values.

2 Answers2

1
<?php
$original = array("red", "red", "blue");
$unique = array_unique($original);
print_r($original);
print_r($unique);
?>
Anne Douwe
  • 681
  • 1
  • 5
  • 19
0
<?php
$a=array("a"=>"red","b"=>"green","c"=>"red");
print_r(array_unique($a));
?>
Nigel Ren
  • 56,122
  • 11
  • 43
  • 55
Santosh Patel
  • 549
  • 2
  • 13