views:

73

answers:

5

Hi,

OK i have two groups of mobile numbers (from mysql) which i need to process, the problem is i need to remove duplicate numbers from the results.

Someone told me about "array_intersect" but I am not very good at these things and I don't see any good examples on the PHP website.

Any help or suggestions is appreciated thanks :)

+3  A: 

Use the array_unique function.

$myArray = array(1, 1, 2, 3, 3, 5);
$myArray2 = array_unique($myArray);

http://php.net/manual/en/function.array-unique.php

Mike
Thank you for all your answers +1 :D
Kyle Hudson
+2  A: 

Put both lists into one array and then run it through array_unique() .

Alex Howansky
+2  A: 

array_intersect isn't quite right — that finds numbers that are in both arrays

$uniques = array_unique(array_merge($array1, $array2));

This merges the two arrays together and then filters out all the unique results (with array_unique)

VoteyDisciple
+1  A: 

Use the array_unique function. Here is an example:

$start = array(1,2,3,3,4,4,4,5);
$unique_result = array_unique($start);
Michael Goldshteyn
+1  A: 

As you wrote about using MySQL, better try using something like

SELECT DISTINCT phone_number FROM table

With DISTINCT each row in the resultset will be unique.

matthiasz
That is part of my first query:
Kyle Hudson