Welcome to WebmasterWorld Guest from 18.104.22.168
I have created a nice script that will convert the URL of my page: http//www.example.com/section/subsection/page_name_goes_here to a nice Breadcrumb, like this: Home > Section > Subsection > Page Name Goes Here. I used functions explode, str_replace and ucwords to separate all the strings, remove any spaces or underlines and make all strings uppercase.
All those words are LINKS directing to their respective paths. This works perfect as a practical dynamic breadcrumb and I am pretty happy with the results, but I've run into a problem.
If my page URL is for instance "http://www.example.com/section/index.php", it will output Home > Section > Index. There are two problems here. First, "Index" is supposed to be replaced with the word "Home". And second, in my Dynamic Breadcrumb, I will never want to make the last element in the array a link.
All I need is a function that can call the last element in my array, so I can work with it within my code and make the necessary changes to that last string in my breadcrumb.
Hopefully your help will solve this small bug and then I'll post my function here so others can use it if they find it useful.
Thank you for your help!
$last = [url=http://uk2.php.net/manual/en/function.count.php]count[/url]($array)-1; // as arrays start from 0
Are you sure that you want all index.php to become home?
As using your example that would lead -
to be changed into
Home > Section > Home
[edited by: PHP_Chimp at 9:04 pm (utc) on Mar. 25, 2008]
I'm messing with my code using your code snippet, PHP_Chimp, let me see what I can get.