Zend - The PHP Company




Menus & Navigation

Add Code


Search Engine Safe URL Parser  

Type: code fragment
Added by: jeffreyharrell
Entered: 23/01/2004
Last modified: 01/12/2003
Rating: *** (3 votes)
Views: 6526
Add this to the top of your page and it will allow you to create search engine safe urls like so: thispage.php/this/equalsthis/andthat/equalsthat


<?php
// split up extra href to get variables
$vars explode('/'$_SERVER['PATH_INFO']); 
array_shift($vars);
reset($vars);


// convert vars into php variables
for ($i=0$i<count($vars); $i=$i+2) {
    
$key $vars[$i];
    
$value $vars[$i 1];
    
    
// avoid  super long input
    
$string_max_length 100;
    
$key substr($key0$string_max_length);
    
$value substr($value0$string_max_length);
    
    
// evaluate as variables
    
eval("$$key = $value;");
}
?>


Usage Example


See the example


Rate This Script





Search



This Category All Categories