# A "," after each line except on the latest one

**URL:** <https://forum.getkirby.com/t/a-after-each-line-except-on-the-latest-one/3694>\
**Category:** Questions\
**Tags:** v2\
**Created:** [March 28, 2016, 9:57am UTC](https://forum.getkirby.com/t/a-after-each-line-except-on-the-latest-one/3694 "2016-03-28T09:57:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tutchi](https://avatars.discourse-cdn.com/v4/letter/t/4af34b/32.png) [@tutchi](https://forum.getkirby.com/u/tutchi)\
**Post date:** [March 28, 2016, 9:57am UTC](https://forum.getkirby.com/t/a-after-each-line-except-on-the-latest-one/3694/1 "2016-03-28T09:57:52Z")

</div>

Hello,

Is it possible to put after each line a **“,”** except on the latest one?  
`['<strong><?php echo $market->market()->html() ?></strong><br /><?php echo $market->place()->html() ?>']`

```
<?php $i=0; foreach($page->markets()->toStructure() as $market): ?>													
	['<strong><?php echo $market->market()->html() ?></strong><br /><?php echo $market->place()->html() ?>']
<?php endforeach ?>

```

---

<div class="post-metadata">

**Author:** ![Ti\_Gr](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/ti_gr/32/98_2.png) [@Ti\_Gr](https://forum.getkirby.com/u/Ti_Gr)\
**Post date:** [March 28, 2016, 10:36am UTC](https://forum.getkirby.com/t/a-after-each-line-except-on-the-latest-one/3694/2 "2016-03-28T10:36:08Z")

</div>

You can do this with css only:

```css
strong:not(:last-child)::after {
  content: ",";
}

```

but I think it would be better to wrap your data in a ul and each market in a li-element

---

<div class="post-metadata">

**Author:** ![rasteiner](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/rasteiner/32/4788_2.png) [@rasteiner](https://forum.getkirby.com/u/rasteiner)\
**Post date:** [April 1, 2016, 1:52pm UTC](https://forum.getkirby.com/t/a-after-each-line-except-on-the-latest-one/3694/3 "2016-04-01T13:52:31Z")

</div>

This probably isn’t a “best practice”, but I find myself often “array\_map” and “join”-ing stuff.

In your case you could do:

```php
<?php
join(', <br>', array_map(function($market) {
  return brick('strong', $market->$market->market()->html());
}, $page->markets()->toStructure());
?>

```

---

<div class="post-metadata">

**Author:** ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)\
**Post date:** [February 6, 2025, 4:59pm UTC](https://forum.getkirby.com/t/a-after-each-line-except-on-the-latest-one/3694/4 "2025-02-06T16:59:52Z")

</div>

Archived on February 6, 2025, 4:59pm UTC


