Trim email list into domain list
Posted
by
hanjaya
on Stack Overflow
See other posts from Stack Overflow
or by hanjaya
Published on 2013-01-28T22:06:13Z
Indexed on
2013/11/05
15:54 UTC
Read the original article
Hit count: 211
The function below is part of a script to trim email list from a file into domain list and removes duplicates.
/* define a function that can accept a list of email addresses */
function getUniqueDomains($list) {
// iterate over list, split addresses and add domain part to another array
$domains = array();
foreach ($list as $l) {
$arr = explode("@", $l);
$domains[] = trim($arr[1]);
}
// remove duplicates and return
return array_unique($domains);
}
What does $domains[] = trim($arr[1]);
mean? Specifically the $arr[1]
. What does [1]
mean in this context? How come variable $arr
becomes an array variable?
© Stack Overflow or respective owner