Jump to content

Email address duplicates


_tina_

Recommended Posts

Yup, my method is too loop through the array and check it manually one by one:

 

Theory =

 

Start Array with Duplicates

Create new array (for this purpose ill name it "NewArray").

Loop through each item of Start Array, and add it to NewArray as long as it doesnt exist.

Then your left with a new array.

 

An Example: (UNTESTED)

<?php

$Array = array(
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]"
);

$nArray = array();

for($i=0;$i<count($Array);$i++){
if(!isset($nArray[$Array[$i]])){
	$nArray[$Array[$i]] = count($nArray) - 1;
}

}
$nArray = array_flip($nArray);

?>

 

Hope this helps,

-CB-

<?php
$array  = array(
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]"
);

$array  = array_map("strtolower", $array);
$unique = array_unique($array, SORT_STRING);

echo '<pre>' . "\n\tStart array:\n\n" . print_r($array, true) . "\n\n" . '</pre>';
echo '<pre>' . "\n\tUnique array:\n\n" . print_r($unique, true) . '</pre>';
?>

 

 

Output:

Start array:

Array
(
    [0] => [email protected]
    [1] => [email protected]
    [2] => [email protected]
    [3] => [email protected]
    [4] => [email protected]
)


Unique array:

Array
(
    [0] => [email protected]
    [1] => [email protected]
    [2] => [email protected]
    [4] => [email protected]
)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.