phparraysarray-unique

PHP - array_unique not changing output


I have an array $tmp:

$a = array(0 => 49, 1 => 49, 2 => 49);

after using array_unique($tmp) I'm getting this output:

Array
(
    [0] => 49
    [1] => 49
    [2] => 49
)

and I want to get

Array
(
    [0] => 49
)

What am I doing wrong? Im new in PHP


Solution

  • $input = array(49,49,49);
    
    $result = array_unique($input);
    
    print_r($result);