Like the title explains a Link Convertor, but what is a link convertor. Well it changes a link to a section link. Clickable / section.
It's quite hard to explain but it works as follows.
http:// www .example.com/index.php?page=home&subpage=About&mpage=5&reply=1547
(Cutted due the board coverts it in to a clickable link.)
The Link Convertor converts into:
Home > About > 5 > 1547
As you see it is not that perfect, to make it use meaning names instead of 5 & 1547, you'll have to come up with a own idea. I am still working on that one.
You could make your link like http:// www .example.com/index.php?page=home&subpage=About&mpage=MPage_5&reply=Reply_1547
It would convert in this
Home > About > MPage_5 > Reply_1547
- <?php
- function link_convertor($url,$skip=0)
- {
- $r = explode('?',$url);
- for ($s = 0; $s < count($s); $s++)
- {
- $a = explode('&',$r[$s]);
- for ($x = 0; $x < count($a); $x++)
- {
- $b = explode('=',$a[$x]);
- $sep[] = $b[0];
- $tmp[] = $b[1];
- }
- for ($i = 0; $i < count($sep); $i++)
- {
- ( $i == 0) ? $sr = '?' : $sr = '&';
- $tmp[$i]= str_replace('%20',' ',$tmp[$i]);
- $linkchr = strlen($tmp[$i]);
- if ( $linkchr > 15 ) {
- $msg = substr($tmp[$i],0,4);
- $msg .= '...';
- $msg .= substr($tmp[$i],$linkchr-5,$linkchr);
- } else {
- $msg = ucfirst($tmp[$i]);
- }
- if ($i == count($sep)-1)
- {
- if ( $tmp[$i] == NULL ) {}
- else {
- $o .= ' » '.ucfirst($tmp[$i]);
- }
- }
- else
- {
- $link = $link.$sr.$sep[$i].'='.$tmp[$i];
- if ( $i < $skip ) { }
- else {
- $o .= ( $i == 0 ) ? ' ' : ' » ';
- $o .= '<a href="'.$link.'" >'.$msg.'</a>';
- }
- }
- }
- }
- // return '<a href="?'.$r[0].'='.$r[0].'" >edede</a>'.$o;
- return $o;
- }
- ?>
example:
- $Link = link_convertor($_SERVER['QUERY_STRING']);
- echo $Link;