⊗ppPmBsCyP 31 of 447 menu

The Cyrillic Character Problem in PHP

The strlen function, like many other PHP string functions, does not work correctly with Cyrillic characters - it counts each Cyrillic letter twice:

<?php echo strlen('абвгд'); // will output 10, not 5 ?>

Therefore, for strings that contain or potentially may contain problematic characters, use the mb_strlen function - it will work correctly:

<?php echo mb_strlen('абвгд'); // will output 5 ?>

Assign a Cyrillic string to a variable. Display the length of your string on the screen.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline