TheNextBigThing
TheNextBigThing

Reputation: 335

PHP replace HTML elements with DIV

I've been reorganising my code to be able to better support old IE browsers. I've put everything that is HTML5 only scripts in IF statements and it all works fine.

I just have one last change I need to make. I've collected all my site into an using ob_start() ... and would like to know the easiest way to replace all html5 elements like article with div. I was going to use simplehtmldom but I don't have mb_character_encoding so it doesn't work. To make it easier I've removed all comments and put all the code on one line in the hope of using a very shiny REGULAR EXPRESSION.

Upvotes: 0

Views: 407

Answers (2)

bfavaretto
bfavaretto

Reputation: 71918

Some options:

  • A simple replace, as suggested by Senad
  • DOMDocument (not the easiest approach)
  • OR... You can leave the HTML the way it is, and use Modernizr on the client side to make older browsers recognize these elements, as well as a bunch of other HTML5/CSS3 features.

Upvotes: 2

Senad Meškin
Senad Meškin

Reputation: 13756

You can replace your <article with <div and </article> with </div>

simple as that no need for complex regular expression

Upvotes: 1

Related Questions