09-28-2007, 11:44 AM
|
#4 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,267
Thanks: 90
|
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($szQuery, 0, -1); } $aQuery = array(); $szItem =& $aMatches[1][$iIndex]; for($iCycle = 0; $iCycle < $iCount; $iCycle++) { $aQuery[] = $aMatches[0][$iCycle]; } $iCount++; $szItem = '<a href="?' . implode('&', $aQuery) . '">' . ucwords(strtolower($szItem)) . '</a>'; } return implode($szSeperator, $aMatches[1]); }
echo '<a href="page.php">TalkPHP.com</a> > ' . 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.
|
|
|