![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
strlen() php function giving the wrong length of unicode characters ?
To get the correct length, use mb_strlen() for Unicode characters.
The PHP code is as follows −
Example
<?php $unicodeValues = 'JohnSmȉth'; echo "The string length with mb_strlen=",mb_strlen($unicodeValues, 'utf8'); echo "
"; echo "The string length with strlen=",strlen($unicodeValues); ?>
Output
The string length with mb_strlen=9 The string length with strlen=10
Advertisements