The part of my code is the following:
while( $pos1 = stripos( $description, '<style' ) ) {
$pos2 = stripos( $description, '</style>' ) + 8;
$description = substr( $description, 0, $pos1 ).
substr( $description, $pos2 ); // <= This string causing the error
}
Sometimes (not all the time!) I receiving the error:
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 107663188 bytes) in /path/to/my/script.php on line 88
88'th line indicated by the '<=' arrow above.
The size of $description
variable is about 100 kB's. Besides I don't see any reason to believe that this code can cause accumulation of memory allocation without to be released.
Do you see any flaws in my code?