View Single Post
Old 09-28-2007, 11:44 AM   #4 (permalink)
Wildhoney
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

I've had fun writing this function :) ! Works like a dream. Even adds in the links for you and best of all, it's all automatic. Don't forget to give TalkPHP.com a mention if you use it! Please.

PHP Code:
function get_crumbs($szSeperator ' > ')
{
    
preg_match_all('/[a-z0-9]+=+([a-z0-9]+)&?/i'$_SERVER['QUERY_STRING'], $aMatches);
    
    
$iCount 1;
    
    for(
$iIndex 0$iIndex count($aMatches[1]); $iIndex++)
    {
        
$szQuery =& $aMatches[0][$iIndex];
        
        if(
substr($szQuery, -1) == '&')
        {
            
$szQuery substr($szQuery0, -1);
        }
        
        
$aQuery = array();
        
$szItem =& $aMatches[1][$iIndex];
        
        for(
$iCycle 0$iCycle $iCount$iCycle++)
        {
            
$aQuery[] = $aMatches[0][$iCycle];
        }
        
        
$iCount++;
        
        
$szItem '<a href="?' implode('&amp;'$aQuery) . '">' ucwords(strtolower($szItem)) . '</a>';
    }
    
    return 
implode($szSeperator$aMatches[1]);
}

echo 
'<a href="page.php">TalkPHP.com</a> &gt; ' get_crumbs(); 
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.

Last edited by Wildhoney : 09-28-2007 at 12:36 PM.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote