Question: What is the best way to compare elments in the same array in PHP, so that if there are two elemets with the same values in array A, I can pass a function as argument to do somthing ?

Answer: 
You can use [`array_count_values`](http://www.php.net/manual/en/function.array-count-values.php) and [`in_array`](http://php.net/manual/en/function.in-array.php) functions as:

```
if(in_array(2,array_count_values($array)) {
  // do something
}

```
I assume you wan't to merge to array and then remove duplicates.

```
$array1 = array('a', 'b', 'c');
$array2 = array(1, 2, 3, 'a');

// array_merge() merges the arrays and array_unique() remove duplicates
var_dump(array_unique(array_merge($array1, $array2)));

// output: array('a', 'b', 'c', 1, 2, 3)

```