Forum Moderators: coopster
../some.html
//example.com/some.html
or http://www.example.com/some.html
all the urls work if i can browse from the browser
but i need to correct them i need to make them all like example.com/some.html any idea ?
array (
0 => "http//www.example.com/some/some.html",
2 => "www.example.com/some/some.html",
3 => "//example.com/some/some.html",
4 => "http://example.com/some/some.html",
5 => "some.html",)
);
all of this i want to output but same [WHATEVER.com...]
Assuming the $urls_array var holds the urls:
$urls_array = array (
0 => "http//www.example.com/some/some.html",
2 => "www.example.com/some/some.html",
3 => "//example.com/some/some.html",
4 => "http://example.com/some/some.html",
5 => "some.html",
);
echo '<pre>';
var_dump($urls_array);
echo '</pre>';
foreach($urls_array as $key => $value) {
$tmp_array = explode('/', $value);
if( is_array($tmp_array) && count($tmp_array) ) {
$urls_array[$key] = 'http://www.example.com/some/' . $tmp_array[count($tmp_array)-1];
}
}
echo '<pre>';
var_dump($urls_array);
echo '</pre>';
so the output should now show the urls with the domain and path included.