How do I remove the last, empty category without PHP functions like
explode
orsubstr
?
You don’t. Look at the source: http://core.trac.wordpress.org/browser/tags/3.6.1/wp-includes/category-template.php#L42 The output you see is intended behavior and there is no filter. My guess is that you are trying to use the function for something it is not meant for.
You could take another approach and use get_ancestors
or wp_list_categories
but substr
or str_replace
would be the easiest.