I want to list a "file" with sub.domain.tld
names, remove sub and list uniqe domain.tld
names
I can't figure out why my output ($list) doubles the last line "voorbeeld.nl"
<?php
$lines=file("list.txt");
$list = array(); //create empty array
foreach ($lines as $line_num => $line) {
$line_explode = explode('.', $line);
array_push($list, $line_explode[1] .'.'. $line_explode[2]);
}
echo "<br>-----------<br>";
foreach(array_unique($list) as $Resuld){
echo '>' . $Resuld .'< <br>';
}
echo "-----------<br>"; ? >
list.txt:
sub1.example.nl
sub2.example.nl
sub1.example.com
sub2.example.com
sub3.example.com
sub1.voorbeeld.nl
sub2.voorbeeld.nl
sub3.voorbeeld.nl
result:
-----------
>example.nl <
>example.com <
>voorbeeld.nl <
>voorbeeld.nl<
-----------