-2

Is there a PHP function that translates ligatures like "Æ" into "AE" and vice versa?

Geremia
  • 4,745
  • 37
  • 43
  • possible duplicate of [PHP Transliteration](http://stackoverflow.com/questions/1284535/php-transliteration) – Sammitch Mar 31 '14 at 21:17
  • You can always build your own if it's not going to be too intensive. A simple `preg_replace()` or similar function can do this quite easily. – Funk Forty Niner Mar 31 '14 at 21:19

2 Answers2

1

You could use one of a few of PHP's functions, one being the preg_replace() function.

<?php

$replace='Æ';
$new=str_replace('Æ', 'AE', $replace); 

echo $new;

Will echo AE


Vice-versa would be:

<?php

$replace='AE';
$new=str_replace('AE', 'Æ', $replace); 

echo $new;

Will echo Æ


Using the str_replace() function, it can be used in sentences, such as:

echo str_replace("Æ","AE","Æ has been replaced from using: ") . "Æ";

Which will echo AE has been replaced from using: Æ

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
0

iconv with "//TRANSLIT" works very well:

$strWithoutLigatures = iconv("utf-8", "us-ascii//TRANSLIT", $strWithLigatures);

(source)

Geremia
  • 4,745
  • 37
  • 43