I’m building a Filter and need the Categories to be exactly like this:
data-filter="category1 category2 category3"
The categories are stored in a Multiselect field and I try to get them like this:
<?php foreach ($project->categories()->split() as $category): ?><?= $category ?><?php endforeach ?>
which gives me this:
data-filter="category1, category2, category3"
Now I want to remove the commas but keep the spaces. I tried
but this removes the spaces too. I also tried to just add Space at the end of <?= $category ?> but this breaks the filter.