I have a code that sort out an array an make sure to keep only the URL that are not in their "Index" form/root domain form.
My regular expression is working but there is still a small thing that insnt working.
Code: Select all
<?php
$array = array('http://www.example.com', 'http://example.com', 'http://this.example.com', 'http://www.example.com/page.html', 'http://example.com/page.html', 'http://this.example.com/page.html', 'http://www.example.com/?page=1', 'http://example.com/?page=1', 'http://this.example.com/?page=1');
for ($x = 0; $x < count($array) - 1; $x++){
$pregmatch = preg_match('-(?i)(?m:^)(\w+://.+/\w.*)(?:\v|\z)+-', $array[$x]);
if ($pregmatch == 1)
{
echo $array[$x]."<br>";
}
}
?>I would like the above code to output the following result at the end:
It doesnt seem to keep the URL followed by a "?". Can someone please correct the above regular expression
Thanks alot!