Given a list of items and a separator, render it in a single line, with separators between. 1 2 3 4 5 6 7 $items = [ "apples", "oranges", "bananas" ]; $separator = " / "; Method 1: Basic foreach This approach is the one that comes to mind first, but it is incorrect because it will emit an additional separator after the last element. 1 2 3 foreach ($items as $value) { echo $value .