Skip to content

Instantly share code, notes, and snippets.

@gsarig
Last active September 6, 2018 20:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gsarig/b66560e52823c36b017da93cdf63199f to your computer and use it in GitHub Desktop.
Save gsarig/b66560e52823c36b017da93cdf63199f to your computer and use it in GitHub Desktop.
PHP function to remove accents from Greek text
<?php
/*
* Run it like so:
*
* $text = 'Your text';
* echo remove_greek_accents( $text );
*/
function remove_greek_accents( $string )
{
$text = [
'Ά' => 'Α',
'Έ' => 'Ε',
'Ή' => 'Η',
'Ί' => 'Ι',
'Ό' => 'Ο',
'Ύ' => 'Υ',
'Ώ' => 'Ω',
'ά' => 'α',
'έ' => 'ε',
'ή' => 'η',
'ί' => 'ι',
'ό' => 'ο',
'ύ' => 'υ',
'ώ' => 'ω',
'ΰ' => 'ϋ',
'ΐ' => 'ϊ',
'ΆΙ' => 'ΑΪ',
'ΆΥ' => 'ΑΫ',
'ΈΙ' => 'ΕΪ',
'ΌΙ' => 'ΟΪ',
'ΈΥ' => 'ΕΫ',
'ΌΥ' => 'ΟΫ',
'άι' => 'αϊ',
'έι' => 'εϊ',
'Άυ' => 'αϋ',
'άυ' => 'αϋ',
'όι' => 'οϊ',
'Έυ' => 'εϋ',
'έυ' => 'εϋ',
'όυ' => 'οϋ',
'Όυ' => 'οϋ',
];
foreach ( $text as $key => $value )
{
if ( $key )
{
$string = str_replace( $key, $value, $string );
}
}
return $string;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment