protected function replace($data, $replacements = null)
    {
        if (!is_array($data) && !is_string($data)) {
            return $data;
        }

        if (!$replacements) {
            $replacements = $this->replacements();
            if (!$replacements) {
                return $data;
            }
        }

        if (is_array($data)) {
            foreach ($data as $key => &$value) {
                $value = $this->replace($value, $replacements);
            }
            return $data;
        }

        return str_replace(array_keys($replacements), array_values($replacements), $data);
    }
protected function replace($data, $replacements = null)
    {
        if (!is_array($data) && !is_string($data)) {
            return $data;
        }

        if (!$replacements) {
            $replacements = $this->replacements();
            if (!$replacements) {
                return $data;
            }
        }

        if (is_array($data)) {
            foreach ($data as $key => &$value) {
                $value = $this->replace($value, $replacements);
            }
            return $data;
        }

        return str_replace(array_keys($replacements), array_values($replacements), $data);
    }
protected function replace ( $ data , $ replacements = null ) { if ( ! is_array ( $ data ) && ! is_string ( $ data ) ) { return $ data ; } if ( ! $ replacements ) { $ replacements = $ this -> replacements ( ) ; if ( ! $ replacements ) { return $ data ; } } if ( is_array ( $ data ) ) { foreach ( $ data as $ key => & $ value ) { $ value = $ this -> replace ( $ value , $ replacements ) ; } return $ data ; } return str_replace ( array_keys ( $ replacements ) , array_values ( $ replacements ) , $ data ) ; }
perform string replacements on a string

Accepts an array, recusively replacing string values
Does nothing to any scalar that's not string

@param array $data
@param array $replacements
@return mixed
perform string replacements on a string