-2

i have an array called res_rooms returning this using 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 
)

then getting unique values like this

$new_room = array_unique($res_rooms);

printing values using print_r($new_room ); but i get nothing at all not even an arror

any ideas? Thanks in advance

bansi
  • 55,591
  • 6
  • 41
  • 52
jq beginner
  • 1,010
  • 3
  • 21
  • 41
  • If you disabled error_reporting or display_errors, then you'll never get an error. Use phpinfo() to check if errors are enabled. Or use `ini_set('display_errors', 'On'); error_reporting(-1);` at the top of your script. – Charlotte Dunois Sep 13 '14 at 11:55
  • Have you got error display on? Is `$res_rooms` your array? – Mateusz Nowak Sep 13 '14 at 11:55

1 Answers1

1

try this code :

$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));

output result :

Old Array :
Array ( [0] => 80 [1] => 50 ) 

New Unique Array :
Array ( [0] => 80 [1] => 50 ) 1 2 3 4 ... 64 Next 
Farshad
  • 1,465
  • 1
  • 9
  • 12