Re: Reg Exp.
| From: | John Holmes | Date: | Wed, 18 Aug 2004 14:50:09 +0000 |
| Subject: | Re: Reg Exp. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-194142@lists.php.net to get a copy of this message | ||
Jay wrote:
Why can´t i get this code to work: $html = $_POST["htmlIn"]; $patterns[0] = "/<strike>/"; $patterns[1] = "/</strike>/"; $patterns[2] = "/align=\"left\"/"; $replacements[0] = "<del>"; $replacements[1] = "</del>"; $replacements[2] = " style=\"text-align:left;\""; $xhtml = preg_replace($patterns, $replacements, $html);Why are you using regular expressions? You're not replacing a pattern, you're replacing a constant. Use str_replace(). $xhtml = str_replace(array('<strike>','</strike>','align="left"'),array('<del>','</del>','style="text-align:left"'),$html); -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com