I want to output a taxonomy so that if one element is selected it shows (e.g. A) that but if two are selected it shows (e.g. A & B) but if more are selected it adds commas then add & to the last one (e.g A, B & C or A, B, C & D)
This is the code I have so far
$colours = get_the_terms( $post->ID, 'colour' );
if ( $colours ) {
$i = 0;
foreach ( $colours as $colour ) {
if(1==$i) {
echo ' & ';
}
echo $colour->name;
$i++;
}
}
This currently does this (e.g. 1 selected = Red then 2 selected = Red and Green) but once more than two are selected it does this (e.g. 3 selected = Red & GreenBlack).