How to forcibly remove spaces in tags

I’m trying to use a tag created by a user as a class.

When the user puts the tag “Jackets and Smocks”,
Can I make it look like “JacketsandSmocks” in the frontend with all spaces removed?

Also, what if I want “jacketsand smocks” to show all lowercase letters?
How can I do it? Please help

  <?php foreach ($page->children()->listed() as $product): ?>
  <?php foreach ($product->servicestags()->split( ) as $stags): ?>
    <li class="<?= $stags ?>">
      <a href="#" data-filter-value=".<?= $stags ?>">
        <span class="tags_img"></span>
        <span class="tags_text"><?= $stags ?></span>
      </a>
    </li>
  <?php endforeach ?>
  <?php endforeach ?>

You probably are looking for the str::slug function.

  <?php foreach ($page->children()->listed() as $product): ?>
  <?php foreach ($product->servicestags()->split( ) as $stags): ?>
    <li class="<?= str::slug($stags) ?>">
      <a href="#" data-filter-value=".<?= str::slug($stags) ?>">
        <span class="tags_img"></span>
        <span class="tags_text"><?= $stags ?></span>
      </a>
    </li>
  <?php endforeach ?>
  <?php endforeach ?>
1 Like

Oh, thank you very much!!! This is what I was looking for!!!

thank you. :heart_eyes:

1 Like