note 60058 added to function.strpos
| From: | samuraj at xmail dot cz | Date: | Sat, 24 Dec 2005 09:38:07 +0000 |
| Subject: | note 60058 added to function.strpos | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-100654@lists.php.net to get a copy of this message | ||
there was a code (from wodzuY2k at interia dot pl) removing all between <script> tags..
but it didn't work if the tag begins like <SCRIPT language=javascript
type=text/javascript>
here is function removing all between "<script" and "/script>"
<?php
function remove_js($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
}
return $contents;
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.strpos.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+60058
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60058&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60058&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60058&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60058&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60058&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60058&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60058&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+60058&report=yes
Search -- http://master.php.net/manage/user-notes.php