开发者

Check if filename contains Umlauts in php

Is there any way, to check in php if a filename开发者_JS百科 has Umlauts?


There's a quick way to do this:

$s = 'äëüïö';

if (preg_match('/&[a-zA-Z]uml;/', htmlentities($s, ENT_COMPAT, 'UTF-8'))) {
    echo 'Filename contains umlaut';
}


<?php
$your_text = "hiÍ :)";
$umlauts = "Ŕ,Á,Â,Ă,Ä,Ĺ,Ç,Č,É,Ę,Ë,Ě,Í,Î,Ď,Ň,Ó,Ô,Ő,Ö,Ř,Ů,Ú,Ű,Ü,Ý,ŕ,á,â,ă,ä,ĺ,ç,č,é,ę,ë,ě,í,î,ď,đ,ň,ó,ô,ő,ö,ř,ů,ú,ű,ü,ý,˙,Ń,ń";
$umlauts = explode(",", $umlauts);
foreach($umlauts as $umlaut){
    if (false !== (strpos($your_text, $umlaut))){
          echo "found ".$umlaut."<br />";
    }
}
?>

working demo

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜