PHP strtolower() special characters not converted

Description:

After converting a string that contains special characters to lower case with strtolower(), the special characters don’t appear correct.

Solution:

strtolower() uses the current locale, not converting special characters. To avoid that use mb_strtolower() whic can take an additional parameter, the internal encoding:

  $str = mb_strtolower($str, 'UTF-8');

Advertisements

About admin

Just another php developer trying to give something back to the community.
This entry was posted in PhP and tagged , , . Bookmark the permalink.

5 Responses to PHP strtolower() special characters not converted

  1. goe says:

    thank you

  2. dnlcyan says:

    Very usefull method! Thanks!

  3. Thanks, straight to the problem

  4. pabLo says:

    Bingo! Many thanks for sharing this solution!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s