Need help with code to edit url output

Discussion in 'PHP' started by mr_bill, Jul 16, 2007.

  1. #1
    I have a script and would like to know if someone could look at these 2 snippets and see they could change the output currently I get this

    /index.php?dir=accounting/

    Would like to change this to be

    /plr-articles/accounting/

    PART 1

    		global $config, $subdir;
    		$exploded = explode('/', $subdir);
    		$c = count($exploded) - 1;
    		$temp = '<a class="autoindex_a" href="' . $_SERVER['PHP_SELF'] . '?dir=">'
    		. Url::html_output(substr(str_replace('/', ' / ', $config -> __get('base_dir')), 0, -2)) . '</a>/ ';
    		for ($i = 0; $i < $c; $i++)
    		{
    			$temp .= '<a class="autoindex_a" href="' . $_SERVER['PHP_SELF']
    			. '?dir=';
    			for ($j = 0; $j <= $i; $j++)
    			{
    				$temp .= Url::translate_uri($exploded[$j]) . '/';
    			}
    			$temp .= '">' . Url::html_output($exploded[$i]) . '</a> / ';
    PHP:
    PART 2

    		}
    		global $words, $config, $subdir;
    		$link = ' <a class="autoindex_a" href="' . $_SERVER['PHP_SELF']
    		. '?dir=' . Url::translate_uri($subdir) . '">'
    		. Url::html_output($dir) . '</a> ';
    		$this -> path_nav = $words -> __get('search results for')
    		. $link . $words -> __get('and its subdirectories');
    		$this -> contents = $this -> matches;
    		unset($this -> matches);
    	}
    PHP:



    I would imagine I could replace the ?dir= with a word but it would still leave me with the index.php part.

    Thanks in advance
     
    mr_bill, Jul 16, 2007 IP
  2. sm9ai

    sm9ai Active Member

    Messages:
    746
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    60
    #2
    There is probably a better way but why not just to

    $link=str_replace('index.php?dir=','plr-articles/', $link);

    or something like that.
     
    sm9ai, Jul 16, 2007 IP
  3. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #3
    Replace:
    
    $temp .= '<a class="autoindex_a" href="' . $_SERVER['PHP_SELF']
                . '?dir=';
    
    PHP:
    With:
    
    $temp .= '<a class="autoindex_a" href="/plr-articles/';
    
    PHP:
    ??
     
    nico_swd, Jul 16, 2007 IP
  4. mr_bill

    mr_bill Banned

    Messages:
    1,292
    Likes Received:
    110
    Best Answers:
    0
    Trophy Points:
    135
    #4
    Will try this as soon as my ftp uploads are done.


    Alright gave it a try doesnt affect it at all
     
    mr_bill, Jul 16, 2007 IP