Page 1 of 1

Filter List Help

Posted: Fri Jul 23, 2010 1:14 pm
by Dan1212
Hey, I want to know how I filter a list of emails that I have by provider Example:

List:
admi@gmail.com
admi@ga.com
ffff@gmail.com
xxx@ga.com
sdsd@ga.com
xxxx@gmail.com

I wish it will display it in the order of the provider Example:

xxxx@gmail.com
ffff@gmail.com
admi@gmail.com
sdsd@ga.com
xxx@ga.com
admi@ga.com

I need help writing code to use some functions

Re: Filter List Help

Posted: Fri Jul 23, 2010 1:29 pm
by Jade
You'll need to use something like usort and compare the substring from @ to the end of the string. Then in each of those you push all beginning of the domain names. Then you can run a regular sort() on each domain within your array. You'll end up with something like this that you can rebuild the sorted list with:

Code: Select all

Array
(
    [aol] => Array
        (
            [0] => cutiepie8
            [1] => hurley.lost
            [2] => jane.doe
        )
    [ga] => Array
        (
            [0] => apple.paltrow
            [1] => dr.suess
            [2] => spongebob
        )
    [gmail] => Array
        (
            [0] => admi
            [1] => fffff
            [2] => zxyr
        )
)