Unstoppable Domains

Extracting domain from email and count (PHP)

Spaceship Spaceship
Watch

jdickson

Established Member
Impact
1
I run a PHPBB bulletin board, and I want to extract my user's email address from the database. What I want is to extract all data after "@" in the email address. From here I want a list that shows the most popular domain names.

Example:

Domain #
yahoo.com 150
webdesigntalk.com 35
hotmail.com 11


Thanks!!!!
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
-scroll down 2 posts-
 
Last edited:
0
•••
(Newbie here)

Do i just copy that code and put it in a php page and it will display results?
 
0
•••
-down 2 posts-
 
Last edited:
0
•••
Runs good, but does not display how many addresses are registered for each domain.

Example:

zyll.net 1
ziplip.com 1
zero.net 1
zcloud.net 1
youmom.com 1
you.com 1
yhti.net 1
yhaoo.com 1
yaoo.com 1
yahoomail.com 1
yahoo.net 1
yahoo.de 1
yahoo.com 1
xm1.biz 1

It shows "1" for each domain listed (over 5000 so didnt want to copy/paste them all) Thanks in advance!
 
0
•••
PHP:
<?php

$mysqlhost = 'localhost';
$mysqluser = 'root';
$mysqlpass = '';
$mysqldata = 'phpbb';

$link = mysql_connect($mysqlhost, $mysqluser, $mysqlpass)or die;
$db   = mysql_select_db($mysqldata, $link) or die;

$query   = "SELECT * FROM phpbb_users";
$result  = mysql_query($query);
$domains = array();

while ($row = mysql_fetch_assoc($result)) 
{
    $domain = substr($row['user_email'], strpos($row['user_email'], '@')+1);
    if (!isset($domains[$domain]))
    {
        $domains[$domain] = array(1, $domain);
    }
    else
    {
        $domains[$domain][0]++;
    }
}

rsort($domains);
foreach ($domains as $domain) 
{
    list($number, $domain) = $domain;
    echo "$domain $number<br />";
}

?>
;)
 
0
•••
Perfect!!! Much thanks!
 
0
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99
Appraise.net

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back