You can do it just by extracting the domain and using it as index for an array with the encrypted values, like so:
$url=$_POST['url'];
$url=nl2br($url);
$url=explode("<br />",$url);
$urls = array();
foreach ($url as $value ){
$arr = explode('www.',$value);
$encrypt = md5($value);
$urls[$arr[1]][]= $encrypt; //this line now fixed, had an error
}
foreach($urls as $key => &$val) {
echo $key . "<br>";
foreach($val as $v) {
echo $v . "<br>";
}
echo "<br>";
}
2
solved parse and sort links [closed]