On Tuesday 26 November 2002 01:42, Leif K-Brooks wrote:
> Thanks, but that doesn't allow nested tags (a [b] tag inside of an [i]
> tag, for example).

If you want to deal with nested tags then it's probably best to replace each 
opening and closing tag individually. Otherwise you might end up with some 
fiendishly complicated regex.

Did I say I preferred the PCRE functions to the EREG ones?

Well using preg_replace() you can put all your search strings in one array and 
all the corresponding replacement strings in another and it'll replace all 
those tags for you in a single operation:

  $text = '[i]This[/i] is a [i]test[/i].';
  $search_for_tags   = array("/\[i\]/", "/\[\/i\]/");
  $replace_with_tags = array("<i>", "</i>");
  $text = preg_replace($search_for_tags, $replace_with_tags, $text);
  print $text;

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
Ignorance must certainly be bliss or there wouldn't be so many people
so resolutely pursuing it. 
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to