Hello everyone,
I want to put every domain, from this list:
http://www.wsmdomains.com/ExpiredDomains/30mar2010.txt
and putting it into variable.
For that I'm using the PHP code "$string = file_get_contents(http://www.wsmdomains.com/ExpiredDomains/30mar2010.txt);"
what is the code that cut every domain and put it into varialbe?
Words on txt file
Moderator: General Moderators
- ridgerunner
- Forum Contributor
- Posts: 214
- Joined: Sun Jul 05, 2009 10:39 pm
- Location: SLC, UT
Re: Words on txt file
This script should do the trick for you:
BTW - This script contains a really good regex for validating DNS hosts.

Code: Select all
<?php
$string = file_get_contents('http://www.wsmdomains.com/ExpiredDomains/30mar2010.txt');
$re = '%^ # regex to match a valid DNS domain
(?!.{256}) # URL total length must be less than 256 chars
(?: # non-capture group for alternation and quantifier
[0-9A-Za-z]\. # each label part can be a single ALPHANUM or
| # up to 63 ALPHANUM with dashes, but must not
[0-9A-Za-z][-0-9A-Za-z]{0,61}[0-9A-Za-z]\. # begin or end with a dash, each followed by a dot.
)* # any number of parts can precede TLD
(?: # group for top level domain (TLD) alternatives
com|edu|gov|int|mil|net|org|biz # these are the recognized top level domains
|info|name|pro|aero|coop|museum # as defined by the regulating organizations see:
|arpa|asia|cat|jobs|mobi|tel|travel # http://data.iana.org/TLD/tlds-alpha-by-domain.txt
|[a-za-z]{2} # generic two ALPHA country TLDS
) # end non-capture group of required TLD
$%ixm';
$count = preg_match_all($re, $string, $matches, PREG_SET_ORDER);
if ($count) {
echo($count . " matches found.\n");
for ($i = 0; $i < $count; $i++) {
echo(
sprintf("Domain #%d = \"%s\"\n", $i + 1, $matches[$i][0])
);
}
}
else {
echo("\nNo matches found.\n");
}
?>- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Words on txt file
That is nice, however if the file is always like that I would use file() and throw away the first 4 lines:
Code: Select all
$lines = file("http://www.wsmdomains.com/ExpiredDomains/30mar2010.txt", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: Words on txt file
ridgerunner - Damn, you are good...
AbraCadaver - thanks you too.
I think I'm gonna need these both codes...
Thanks!
AbraCadaver - thanks you too.
I think I'm gonna need these both codes...
Thanks!