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:

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

Recently, we came across a problem, while developing a new version of the Notification plugin. We wanted to tidy up our codebase and one of the tasks was to rename...

Following the success of the Notification plugin, we knew that personalization was the direction we would pursue. Thanks to feedback, we were easily able to identify the needs of the...

WordPress Cron is pretty basic and doesn’t allow for much configuration in terms of schedules. By default, you can run your events with a specific interval, like daily, weekly, or...

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.