NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming > CODE
Reload this Page Simple Domain List Cleaner in PHP

CODE This forum is for posting code snippets and example scripts that aren't quite tutorials, but could be useful for others. You may post code snippets and/or completed scripts that you've written and want to share here.

Advanced Search
7 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 04-16-2004, 03:05 PM THREAD STARTER               #1 (permalink)
Senior Member
Join Date: Aug 2002
Posts: 1,255
deadserious has a spectacular aura aboutdeadserious has a spectacular aura about
 



Thumbs up Simple Domain List Cleaner in PHP


This simply extracts the first occurence of a domain name from every line you enter in the textarea and only prints the domain once if it occurs on multiple lines. You can change the regex to better suit your needs. I have it the way it is to prevent it from matching things such as file.php or file.gif if you enter a bunch of source code or something.
????: NamePros.com http://www.namepros.com/code/27325-simple-domain-list-cleaner-in-php.html

PHP Code:
<html> 
<head> 
<title>Domain List Cleaner</title>

<body>

<center> 
????: NamePros.com http://www.namepros.com/showthread.php?t=27325
<form method="post" action="">
<textarea name="domains" rows="15" cols="60">
<?php
$temparray 
= array(); 
$domains $_POST['domains'];
if (
$domains)
{
    
$list split("\r\n"$domains); 
    foreach (
$list as $value
    { 
        
preg_match("/[a-z-A-Z0-9-]+\.(com|net|org|us|biz|info|cc)/"$value$matches); 
        
        for (
$i 0$i count($matches); $i++) 
        { 
            
array_push($temparray$matches[0]);
        } 
    }
    
    
$uniquearray array_unique($temparray);

    foreach (
$uniquearray as $uniquevalue
    {
        echo 
"$uniquevalue\n";
    } 
}
?>
</textarea>
<br />
<input type="submit" value="Process">
</form>
</center>

</body>
</html>
Last edited by deadserious; 04-16-2004 at 03:08 PM.
deadserious is offline  
Old 04-16-2004, 03:36 PM   #2 (permalink)
Senior Member
Join Date: May 2003
Posts: 2,187
adam_uk is a jewel in the roughadam_uk is a jewel in the roughadam_uk is a jewel in the rough
 


Breast Cancer
so if i was to enter

bob.com
bob.org
bob.net
bob.com

it would remove the first bob.com?
adam_uk is offline  
Old 04-16-2004, 04:03 PM THREAD STARTER               #3 (permalink)
Senior Member
Join Date: Aug 2002
Posts: 1,255
deadserious has a spectacular aura aboutdeadserious has a spectacular aura about
 



Yes it would, or actually the second

Here's the results for pasting the entire html source code from the namepros.com homepage:

namepros.com
TD.info
vBStyles.net
google.com
DomainEmpire.com
CoolHost.com
googlesyndication.com
qksrv.net


deadserious is offline  
Old 04-17-2004, 03:19 AM   #4 (permalink)
Senior Member
Join Date: May 2003
Posts: 2,187
adam_uk is a jewel in the roughadam_uk is a jewel in the roughadam_uk is a jewel in the rough
 


Breast Cancer
ah right wicked!

thats a handy little script
adam_uk is offline  
Old 05-13-2004, 03:06 AM   #5 (permalink)
NamePros Regular
 
JNav's Avatar
Join Date: Dec 2003
Location: Australia
Posts: 811
JNav will become famous soon enoughJNav will become famous soon enough
 



nice! looks like a sweet little script, gonna give it a try.. thanks!
JNav is offline  
Old 05-13-2004, 06:05 AM   #6 (permalink)
Senior Member
 
InteractAsia's Avatar
Join Date: Nov 2003
Location: Merlion City
Posts: 1,208
InteractAsia has a spectacular aura aboutInteractAsia has a spectacular aura about
 



nice script there..thanks
__________________
ermm..do i need to put my sig here?
Free Short URL | Free Reseller Hosting | Free cPanel Blog Hosting
Hottest New Posters & Prints
InteractAsia is offline  
Old 05-26-2004, 05:49 PM   #7 (permalink)
Account Suspended
 
axilant's Avatar
Join Date: May 2004
Location: /etc/passwd
Posts: 2,178
axilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to behold
 

Member of the Month
July 2005

very nice code... i think i might use it
axilant is offline  
Old 05-26-2004, 07:08 PM   #8 (permalink)
Man from Manila
 
armstrong's Avatar
Join Date: Jul 2003
Location: The Net
Posts: 6,022
armstrong has much to be proud ofarmstrong has much to be proud ofarmstrong has much to be proud ofarmstrong has much to be proud ofarmstrong has much to be proud ofarmstrong has much to be proud ofarmstrong has much to be proud ofarmstrong has much to be proud of
 

NamePros Hall of Fame
Autism Special Olympics
hmm. what happens if there are several valid domains in one line?
armstrong is offline  
Old 05-27-2004, 03:34 AM   #9 (permalink)
Account Suspended
 
axilant's Avatar
Join Date: May 2004
Location: /etc/passwd
Posts: 2,178
axilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to behold
 

Member of the Month
July 2005

thats what i was thinking as well.... I'll try to fix that
axilant is offline  
Old 05-30-2004, 11:24 AM THREAD STARTER               #10 (permalink)
Senior Member
Join Date: Aug 2002
Posts: 1,255
deadserious has a spectacular aura aboutdeadserious has a spectacular aura about
 



Quote:
Originally posted by armstrong
????: NamePros.com http://www.namepros.com/showthread.php?t=27325
hmm. what happens if there are several valid domains in one line?
If you change this line:

$list = split("\r\n", $domains);

to something like this:

$list = split(" +", $domains);

That might do it
deadserious is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


 
All times are GMT -7. The time now is 03:19 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger