You must look for content that is in Greek letters using strtoupper and strtolower

I am currently working on a GREEK project. In this project, all the contents of GREEK and that I have a search function. The search process is good. But strtoupper () did not convert Greek to uppercase, and strtolower () did not convert Greek to lowercase.

But for English, it works fine. Is there any possible way to convert Greek letters to the UPPER and LOWER case.

thank

Fero

+3
source share
5 answers

There is no reason mb_strtolower()and mb_strtoupper()should not work:

<?php

header('Content-Type: text/html; charset=utf-8');

echo mb_strtoupper('παπακωνσταντινου', 'UTF-8'); // ΠΑΠΑΚΩΝΣΤΑΝΤΙΝΟΥ
echo mb_strtolower('ΠΑΠΑΚΩΝΣΤΑΝΤΙΝΟΥ', 'UTF-8'); // παπακωνσταντινου

?>

Use mb_convert_case()is another option, especially if you want to emulate ucwords():

<?php

header('Content-Type: text/html; charset=utf-8');

echo mb_convert_case('παπακωνσταντινου', MB_CASE_UPPER, 'UTF-8'); // ΠΑΠΑΚΩΝΣΤΑΝΤΙΝΟΥ
echo mb_convert_case('ΠΑΠΑΚΩΝΣΤΑΝΤΙΝΟΥ', MB_CASE_LOWER, 'UTF-8'); // παπακωνσταντινου
echo mb_convert_case('παπακωνσταντινου', MB_CASE_TITLE, 'UTF-8'); // Παπακωνσταντινου

?>
+6

:

mb_strtoupper
mb_strtolower
+2

Mb_StrToUpper Mb_StrToLower

They are part of the Multibyte String Function , which can work with multibyte character encodings.

+1
source

$ str = 'παπακωνσταντινου';

$ test = mb_convert_case ($ str, MB_CASE_UPPER, "UTF-8");

This is the correct syntax.

thanks to all the guys

0
source

Source: https://habr.com/ru/post/1726883/


All Articles