fbpx
Search
Close this search box.

Home / Blog

 / 
Close unclosed HTML tags in PHP

Close unclosed HTML tags in PHP

Recently I stumped upon a handy WordPress function which closes HTML tags.

The function name is force_balance_tags().

Taking as an example unclosed list items:

echo force_balance_tags( '<ul>
  <li>this
  <li>is
  <li>a
  <li>list
</ul>' );

It will produce something like this:

<ul>
  <li>this
  </li><li>is
  </li><li>a
  </li><li>list
</li></ul>

Share This Article:

Picture of Kuba Mikita

Kuba Mikita

Share This Article:

Summary

Picture of Kuba Mikita

Kuba Mikita

Share This Article:

Latest updates, discounts and more!

Get the most recent updates on WordPress automation, fresh plugins, new features and price cuts.

Related articles

The Notification plugin just received its third major update, with a complete code refactor to enhance performance and user experience. This rewrite brings improved functionality, so if you’re a Notification...

Logging in as an administrator, the easy way with a short snippet. Site files access required....
In this post, we show how to write an email that removes you from the noise with a Beautiful Email showcasing your latest blog posts and top-of-mind content in case...

WordPress Plugins that get the job done

With years of experience creating client websites, we bring our experience to functional WordPress plugins.

Easy to use for everyone

Regardless of experience level, you can easily use our products.

Top-notch Support included

We treat our clients seriously and focus heavily on support. Reviews backs this up!

Extensible and developer friendly

You're the same developer as we are. Our code is clean and extensible, just the way you like.