Below it's my code to show list of categories:
foreach((get_the_category()) as $childcat) {
if (cat_is_ancestor_of(2, $childcat)) {
echo '<a href="'.get_category_link($childcat->cat_ID).'">';
echo $childcat->cat_name . '</a> / ';
}
}
This code give me results like this: category1 / category2 / category 3 /
But i want to have result without last mark:
category1 / category2 / category 3
I know i should use rtrim but i don't know how to do this in this case