Check if filename contains Umlauts in php

73

Is there any way, to check in php if a filename has Umlauts?

592

Answer

Solution:

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';
}
362

Answer

Solution:

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

working demo

People are also looking for solutions to the problem: datetime - php "countdown til" and "since time" GMT UTC time function

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.