- Impact
- 6
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.
PHP:
<html>
<head>
<title>Domain List Cleaner</title>
<body>
<center>
<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: