Strtolower does not work with Arabic characters

My site allows users to register with Arabic / English names

I am trying to convert the username and last name of the user to lowercase

I use this function

$first_name = strtolower ( $_POST['first_name'] );

if I try to put the Arabic name, I get this code (ø¹ù "ø§ø¡)

try it yourself.

<?
echo 'مصر'; // return مصر
echo strtolower('مصر'); // return ø¹ù„ø§ø¡
?>

? >

+3
source share
1 answer

You cannot use strtolowerUTF-8 for an encoded string, only according to ISO 8859-1. Use instead . You also need to specify the encoding used, make sure that it is installed correctly (possibly ). mb_strtolower()"UTF-8"

<?
echo 'مصر'; // return مصر
echo mb_strtolower('مصر', 'UTF-8'); // return مصر
?>
+9
source

All Articles