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

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: function highlight_phrase áéíóú - ÁÉÍÓÚ (/showthread.php?tid=28803)



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~%.:_\-+*');