I'm using array_unique() to remove a duplicate value but it gives me an error when the value comes from a string then converted using explode, and values not displaying correctly
I'm using http://phptester.net/ to test
$email = 'general@t.com,info@t.com,info@t.com,jaa@t.com';
$emailList = array_unique(array_filter(array_map('trim',explode(',',$email))));
for($i = 0; $i < count($emailList); $i++){
echo $emailList[$i];
}
I would do it like this :
$email = 'general@t.com,info@t.com,info@t.com,jaa@t.com';
$emailList = (array_map('trim',explode(',',$email)));
$result = array_unique($emailList);
var_dump($result);
In case you want to print the array values, using for-loop, you can do like this:
$email = 'general@t.com,info@t.com,info@t.com,jaa@t.com';
$emailList = (array_map('trim',explode(',',$email)));
$result = array_unique($emailList);
for($i = 0; $i < count($emailList); $i++){
if( $emailList[$i]!=null)
echo $emailList[$i];
}