Jump to content


Convert String to valid XHTML


1 reply to this topic

#1 AndyMills

    Young Padawan

  • Members
  • Pip
  • 26 posts
  • Gender:Male
  • Location:United Kingdom

Posted 29 January 2009 - 05:51 AM

Hi All

I'm working on a CMS which makes use of the ContentEditable features available in most browsers nowadays.  Unfortunately, the code generated from this is not XHTML compliant.  I've managed to iron out most of the kinks using the str_replace function; however, I still have to find a way to make all of the tags lowercase.  I'm assuming it should be done with a regular expression replacement (search for strings that start with a < and contain upto a certain amount of letters and numbers afterwards).  I'm pretty rubbish at regular expressions, so could someone tell me how to use preg_replace (or any other function you think might work better) to make the tags lowercase.

Thanks in advance! :)

-Andy

#2 Jonne

    Young Padawan

  • Members
  • Pip
  • 8 posts
  • Gender:Male
  • Location:Finland
  • Interests:Floorball, PHP, Discovering new things!

Posted 30 January 2009 - 05:21 AM

You might want to use the way that BBCODEs work.
So basically you make array where you have [THIS => replaced] and use preg_replace($patterns, $replacements, $string);
That might be an solution for your problem, if I even got it right what you want :-)

EDIT: ////////////

You might want to take a look to this nice small tutorial written by HaloprO @ Pixel2Life :

http://www.pixel2lif...showtopic=10659 [PHP] BBCode Parser, [b], [i], [u], [url], [img], [code]

Edited by Jonne, 30 January 2009 - 05:30 AM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users