url - Make a local link global /test.php -> example.com/test.php -
url - Make a local link global /test.php -> example.com/test.php -
i've been working on spider algorithm , have been having issues links.
example of how works:
got content -> example.com/bob/index.php?page=funny+faces
content :
class="lang-html prettyprint-override"><html> <a href="../jack/index.php"> link 1 </a> <a href="/bob_more_info"> link 2 </a> <a href="http://www.youtube.com"> link 3 </a> </html>
pass content through links function
links function returned
[0] = ../jack/index.php
[1] = /bob_more_info
[2] = http://www.youtube.com
now need create these links urls page got them on (example.com/bob/index.php?page=funny+faces)
so
[0] -> ../jack/index.php into example.com/jack/index.php
[1] -> /bob_more_info into example.com/bob/bob_more_info
[2] -> http://www.youtube.com
what asking function can conversion. mine, it's not working , becoming pain. if edit or write me function much appreciated. in advance.
here function currently:
class="lang-cs prettyprint-override">//example: //$newurl = urlfix("example.com/bob/index.php?page=funny+faces", "../jack/index.php"); function urlfix ($url, $ext) { if(is_valid_url($url."/")) { $url .= "/"; } $ar1 = explode("/", $url); if(count($ar1) == 1) { homecoming $url."/".$ext; } $target = $ar1[count($ar1) - 1]; if($target == "") { homecoming $url.$ext; } if(strpos(" ".$target, ".")) { $cur = ""; for($i = 0; $i < count($ar1) - 1; $i ++) { $cur .= $ar1[$i]; $cur .= "/"; } homecoming $cur.$ext; } homecoming $url."/".$ext; }
use explode() split $url array delimited /, $bits[0] illustration contain example.com
php url hyperlink local
Comments
Post a Comment