PHP: strtr() memory exhausted

65 Views Asked by At

I have a function that checks and decodes the content from various variables:

public static function decode($content, $flag=ENT_NOQUOTES){
    if ( !empty($content) && is_string($content) && !is_numeric($content) && !is_array($content) && !is_object($content) ) {
        if (filter_var($content, FILTER_VALIDATE_URL)) {
            $content = rawurldecode($content);
        } else {
            $content = htmlspecialchars_decode($content, $flag);
            $content = html_entity_decode($content, $flag);
            $content = strtr($content, array_flip(get_html_translation_table(HTML_ENTITIES, $flag)));
        }
    }
    return $content;
}

In some cases with some clients I run into a memory problem where the strtr() function consumes all the memory.

The problem is I can't figure out why.

0

There are 0 best solutions below