Skip to content

Instantly share code, notes, and snippets.

@lawebfabric
Last active December 1, 2018 15:29
Show Gist options
  • Save lawebfabric/5e55b5293726dae72d91e56de180abdb to your computer and use it in GitHub Desktop.
Save lawebfabric/5e55b5293726dae72d91e56de180abdb to your computer and use it in GitHub Desktop.
Simple (output modifier) snippet to replace accent caracters with caracters whithout accent
<?php
//-----------------------------------------------------------
// noaccents
//-----------------------------------------------------------
/*
* @author: Steeve from lawebfabric
* @website: http://www.lawebfabric.com
* @tutorial modx website: http://www.tutocms.fr/
*/
/*
* Example : [[*maTv:noaccents]] or [[*content:noaccents]]
*
*/
$search = array(‘À’,‘Á’,‘Â’,‘Ã’,‘Ä’,‘Å’,‘Ç’,‘È’,‘É’,‘Ê’,‘Ë’,‘Ì’,‘Í’,‘Î’,‘Ï’,‘Ò’,‘Ó’,‘Ô’,‘Õ’,‘Ö’,‘Ù’,‘Ú’,‘Û’,‘Ü’,‘Ý’,‘à’,‘á’,‘â’,‘ã’,‘ä’,‘å’,‘ç’,‘è’,‘é’,‘ê’,‘ë’,‘ì’,‘í’,‘î’,‘ï’,‘ð’,‘ò’,‘ó’,‘ô’,‘õ’,‘ö’,‘ù’,‘ú’,‘û’,‘ü’,‘ý’,‘ÿ’);
$replace = array(‘A’,‘A’,‘A’,‘A’,‘A’,‘A’,‘C’,‘E’,‘E’,‘E’,‘E’,‘I’,‘I’,‘I’,‘I’,‘O’,‘O’,‘O’,‘O’,‘O’,‘U’,‘U’,‘U’,‘U’,‘Y’,‘a’,‘a’,‘a’,‘a’,‘a’,‘a’,‘c’,‘e’,‘e’,‘e’,‘e’,‘i’,‘i’,‘i’,‘i’,‘o’,‘o’,‘o’,‘o’,‘o’,‘o’,‘u’,‘u’,‘u’,‘u’,‘y’,‘y’);
$output = str_replace($search, $replace, $input);
return $output;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment