Find the Non-Repeating Elements in an Array

后端 未结 4 1826
别跟我提以往
别跟我提以往 2021-01-23 04:24

My array is :

$array= array(4,3,4,3,1,2,1);

And I\'d like to output it like below:

Output = 2 

(As 2 i

4条回答
  •  孤城傲影
    2021-01-23 05:06

    If in your scenario there will be only one unique value you could use:

    $array= array(4,3,4,3,1,2,1);
    $singleValue = array_search(1, array_count_values($array));
    var_dump($singleValue) // Outputs: 2
    

提交回复
热议问题