CodeIgniter URL_TITLE UTF8 Characters?

I have a problem with codeigniter something like this, I have a line like this

$string="Mučnina – problem u vožnji!"; 

When I do something like this

 $url_title = url_title($string, '_', TRUE); 

I got it

 $string="munina_problem_u_vonji"; 

Big difference?

How to change url_title parameters?

+4
source share
2 answers

This is what I did:

1. go to application / config / foreign_chars.php

2. added

 '/š/' => 's', '/đ/' => 'd', '/č/' => 'c', '/ć/' => 'c', '/ž/' => 'z', '/Š/' => 'S', '/Đ/' => 'D', '/Č/' => 'C', '/Ć/' => 'C', '/Ž/' => 'Z', 

3. Just call

 $clean=convert_accented_characters($string); $url_title = url_title($clean, '_', TRUE); 
+3
source

The built-in URL header function will not work on its own, as it simply replaces all matches [^a-z0-9 _-] an empty string.

Try to run convert_accented_characters() first on your input, this function replaces it in the config/foreign_chars.php , so something like this:

 url_title(convert_accented_characters($string), '_', TRUE); 
+2
source

Source: https://habr.com/ru/post/1485865/


All Articles