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 -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -