note 102589 added to function.preg-replace
| From: | me at perochak dot com | Date: | Wed, 23 Feb 2011 05:57:35 +0000 |
| Subject: | note 102589 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-177242@lists.php.net to get a copy of this message | ||
If you would like to remove a tag along with the text inside it then use the following code.
preg_replace('/(<tag>.+?)+(<\/tag>)/i', '', $string);
example
$string='<span class="normalprice">55 PKR</span>';
$string = preg_replace('/(<span
class="normalprice">.+?)+(<\/span>)/i', '', $string);
This will results a null or empty string.
$string='My String <span class="normalprice">55 PKR</span>';
$string = preg_replace('/(<span
class="normalprice">.+?)+(<\/span>)/i', '', $string);
This will results a " My String"
----
Server IP: 69.147.83.197
Probable Submitter: 119.152.32.7
----
Manual Page -- http://www.php.net/manual/en/function.preg-replace.php
Edit -- https://master.php.net/note/edit/102589
Del: integrated -- https://master.php.net/note/delete/102589/integrated
Del: useless -- https://master.php.net/note/delete/102589/useless
Del: bad code -- https://master.php.net/note/delete/102589/bad+code
Del: spam -- https://master.php.net/note/delete/102589/spam
Del: non-english -- https://master.php.net/note/delete/102589/non-english
Del: in docs -- https://master.php.net/note/delete/102589/in+docs
Del: other reasons-- https://master.php.net/note/delete/102589
Reject -- https://master.php.net/note/reject/102589
Search -- https://master.php.net/manage/user-notes.php