Breadcrumb dividers...how to append correctly?

Hi, I’m working with a press release page where everything is pulled in dynamically and am trying to add dividers between the breadcrumb dates at the top of the page. I’ve posted the full code below but the line in question is this:

$output_year .= '<a href="#'.$year->year.'">'.$year->year.'</a> ';

Now, I can append the divider like this:

$output_year .= '<a href="#'.$year->year.'">'.$year->year.'</a> ' . '| ';

This works for the most part but because the divider is appended after each date, it also occurs after the last one which I don’t want. I just want the dividers to show up between the dates, not before the first one or after the last one? Any idea how I go about coding this in?

Full Code:


<strong>Press Releases</strong><br />
<?php
global $language;
$sql = "SELECT distinct(date_format( str_to_date( title, '%e %M %Y' ) , '%Y' ) ) as year FROM {node} where status = 1 and type='story' and language='".$language->language."' order by year desc";
$result = db_query($sql);
$output_year = '';
$output_news = '';
while ($year = db_fetch_object($result)) {
  $output_year .= '<a href="#'.$year->year.'">'.$year->year.'</a> ';
  $output_news .= '<a name="'.$year->year.'"></a>' . '<h1>'.$year->year.' Press Releases</h1>';
  $sql_news = "SELECT * from {node} WHERE status = 1 and type='story'  and language='".$language->language."' and date_format( str_to_date( title, '%e %M %Y' ) , '%Y' ) =".$year->year.' ORDER BY str_to_date( title, "%e %M %Y" ) DESC';
  $result_news = db_query($sql_news);
  while ($news = db_fetch_object($result_news)){
    $tmp_node = node_load(array(nid=>$news->nid));
    $href = 'node/'.$tmp_node->nid;
    if ($tmp_node->path){
        $href = $tmp_node->path;
    }
    $output_news .= '<b>'.$tmp_node->title.'</b><br />'.$tmp_node->field_teaser[0]['value'].'<br /><a href="/'.$href.'">'.'Read</a><br /><br />';
  }
$output_news .= "<br />";
}
print $output_year.'<br><br><br>';
print $output_news;
?>

Any help’s appreciated as I’m just getting my head wrapped around PHP.

echo rtrim( $output_year, "| ") . ‘<br><br><br>’ ;

( <br><br><br> = yeuch yeuch yeuch ) :wink:

That worked. Thanks! And…yes, I know about the <br /> tags, print vs echo, and I agree wholeheartedly. The site was a hand-down from a company that did functional work but that’s about it…they used old site code when porting from a standard html site into a CMS rather than re-writing it…concentrated more on custom CMS functionality/php programming…it works but is in poor shape from a semantically-correct standpoint so that leaves me to add one band-aid at a time.

Another approach is:
(Since you are in a loop)

$count 			= 1;
$count_from_db 	= $from_db;
while(){
	if($count_from_db != $count){
		echo '|'; //this will be excluded in last row
	}
	$count++;
}