note 89878 modified in function.strip-tags by danbrown

From: Date: Thu, 26 Mar 2009 20:53:45 +0000
Subject: note 89878 modified in function.strip-tags by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-152496@lists.php.net to get a copy of this message
An easy way to clean a string of all CDATA encapsulation. <?php function strip_cdata($string) { preg_match_all('/<!\[cdata\[(.*?)\]\]>/is', $string, $matches); return str_replace($matches[0], $matches[1], $string); } ?> Example: echo strip_cdata('<![CDATA[Text]]>'); Returns: Text --was-- An easy way to clean a string of all CDATA encapsulation. function strip_cdata($string) { preg_match_all('/<!\[cdata\[(.*?)\]\]>/is', $string, $matches); return str_replace($matches[0], $matches[1], $string); } Example: echo strip_cdata('<![CDATA[Text]]>'); Returns: Text http://php.net/manual/en/function.strip-tags.php

« previous php.notes (#152496) next »