I need to compare 3 different URLs, in order to that i need to make them identical like example.com
I've created a preg_match()
. So far i've accomplished to make the urls to example.com
when the url looks like : http://www.example.com
, http://www.example.com/foo
and www.example.com
. The only issue what im getting is, when the url looks like: http://example.com
it doesnt preg_match
it.. I think it recognizes it as 'clean'
so it skips it. Can you guys tell me what im doing wrong?
My code looks like this :
$pattern = '/.*[\.\/]([a-zA-Z0-9\-]+\.\w{2,3})\/.*/';
$results = $reader->noHeading()->takeColumns(1)->toArray();
$cleaned = array();
for($i = 0; $i < count($results); $i++){
if(preg_match($pattern,$results[$i][0],$cleaned[$i]) === 1){
echo "<pre>";
var_dump($cleaned[$i][1]);
echo "</pre>";
}
}
Thanks for your time!