php - Remove accent characters in twig -


please how can remove accent in variable url example téléphone telephone

 <td><a href="{{ path('search_city',{'cityname':url  }) }}">{{ city }}</a></td>  

you can iconv transliteration activated.

create filter with

$remove_accent = new twig_simplefilter('remove_accent', function ($string) {     return iconv('utf-8', 'us-ascii//translit', $string); }); 

and add twig environment with

$twig = new twig_environment($loader); $twig->addfilter($remove_accent); // add 

then call in twig file with

{{ city | remove_accent }} 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -