I want to group this array. please help me..
Array
(
[0] => dghfdih@hjuh.cvh
[1] => dghfdih@hjuh.cvh
[2] => dghfdih@hjuh.cvh
)
And my expected output is
Array
(
[0] => dghfdih@hjuh.cvh
)
I want to group this array. please help me..
Array
(
[0] => dghfdih@hjuh.cvh
[1] => dghfdih@hjuh.cvh
[2] => dghfdih@hjuh.cvh
)
And my expected output is
Array
(
[0] => dghfdih@hjuh.cvh
)
Look at array_unique
which will remove duplicates from the array.
<?php
// Assuming your array is stored as $arr
$arr = array(
'dghfdih@hjuh.cvh',
'dghfdih@hjuh.cvh',
'dghfdih@hjuh.cvh'
);
// Remove the duplicates
$arr = array_unique($arr);
// Print to test
echo '<pre>'.var_export($arr, TRUE).'</pre>';
I assume you wish to remove duplicates, luckily PHP has a function called array_unique
Use it like so:
$array = array( "dghfdih@hjuh.cvh", "dghfdih@hjuh.cvh", "dghfdih@hjuh.cvh" );
$array = array_unique( $array );