|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[1999-07-23 14:41 UTC] zeev at cvs dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 18:00:01 2025 UTC |
Here is a sequence of code which I found doesn't work. I have a better way of performing this function with regexp's but this should work without crashing anyway. I have had a play with this function removing bits here and there to find out exactly where the problem is. It seems that if you remove this section. ----------- case "<": $stack++; break; case ">": $stack--; break; ----------- There is no crash. Also if the for loop is removed there is no crash. Also if I replace the switch statement line with this ------------ $temp = $str[$i]; switch($temp) { ------------ It works too. Thought that might make it a bit easier to track down. Here is the function below. ------------------------------ function StripHTML($str) { $dest = ""; $stack = 0; for ($i=0;$i<strlen($str);$i++) { switch($str[$i]) { case "<": $stack++; break; case ">": $stack--; break; default: if (!$stack) { $dest .= $str[$i]; } break; } } return $dest; } ---------------------------