note 31021 modified in function.strpos by aidan
| From: | aidan@php.net | Date: | Thu, 10 Jun 2004 07:00:37 +0000 |
| Subject: | note 31021 modified in function.strpos by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-70817@lists.php.net to get a copy of this message | ||
//this loop removes <script>.*</script> tags from HTML contents.
<?php
while(true)
{
$begPos = strpos($contents,"<script");
if ($begPos===false) break; //all tags were found & replaced.
$endPos = strpos($contents,"script>",$begPos+strlen("<script"));
$tmp = substr($contents,0,$begPos);
$tmp .= substr($contents,$endPos+strlen("script>"));
$contents = $tmp;
if ($loopcontrol++>100) break; //loop infinity control
continue; //search again
};
?>
--was--
//this loop removes <script>.*</script> tags from HTML contents.
while(true)
{
$begPos = strpos($contents,"<script");
if ($begPos===false) break; //all tags were found & replaced.
$endPos = strpos($contents,"script>",$begPos+strlen("<script"));
$tmp = substr($contents,0,$begPos);
$tmp .= substr($contents,$endPos+strlen("script>"));
$contents = $tmp;
if ($loopcontrol++>100) break; //loop infinity control
continue; //search again
};
http://www.php.net/manual/en/function.strpos.php