CodeIgniter Forums
function highlight_phrase áéíóú - ÁÉÍÓÚ - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: function highlight_phrase áéíóú - ÁÉÍÓÚ (/thread-28803.html)



function highlight_phrase áéíóú - ÁÉÍÓÚ - El Forum - 03-22-2010

[eluser]Unknown[/eluser]
áéíóú - ÁÉÍÓÚ characters do not adequately replace...
return preg_replace('/('.preg_quote($phrase, '/').')/ui', $tag_open."\\1".$tag_close, $str);
Code:
function highlight_phrase($str, $phrase, $tag_open = '<strong>', $tag_close = '</strong>')
    {
        if ($str == '')
        {
            return '';
        }
    
        if ($phrase != '')
        {
            return preg_replace('/('.preg_quote($phrase, '/').')/ui', $tag_open."\\1".$tag_close, $str);
        }

        return $str;
    }

In config.php file(to accept any character on URL):
Code:
$config['permitted_uri_chars'] = utf8_encode('áéíóúÁÉÍÓÚäëïöüÄËÏÖÜñÑ a-z 0-9~%.:_\-+*');