- preg_replace_callback: documentation ( source)
<?php
echo preg_replace_callback('/(ä)|(ö)|(ü)|(Ä)|(Ö)|(Ü)|(ß)/', 'äöüÄÖÜß', function($matches){
foreach($matches as &$match){
switch($match){
case 'ü':
$match = 'ue';
break;
case 'ö':
$match = 'oe';
break;
case 'ä':
$match = 'ae';
break;
case 'Ü':
$match = 'Ue';
break;
case 'Ö':
$match = 'Oe';
break;
case 'Ä':
$match = 'Ae';
break;
case 'ß':
$match = 'ss';
break;
}
}
});