homepage Welcome to WebmasterWorld Guest from 54.225.57.156
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
links issue
nick patrick




msg:3855357
 7:54 pm on Feb 22, 2009 (gmt 0)

i am just getting a issue i am getting all the <a> tags from a remote page its give out like

../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 ?

 

nick patrick




msg:3855378
 8:37 pm on Feb 22, 2009 (gmt 0)

cant understand here more detail with example

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...]

enigma1




msg:3855761
 1:34 pm on Feb 23, 2009 (gmt 0)

right you can deploy the filters you want for the various conditions. So in this example I assume you want to filter by the page html.

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved