note 124660 added to intlchar.tolower
| From: | Patanjali@php.net | Date: | Tue, 28 Jan 2020 23:25:20 +0000 |
| Subject: | note 124660 added to intlchar.tolower | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-213973@lists.php.net to get a copy of this message | ||
A function to convert a Unicode string to lowercase, directly replacing mb_strtolower, by converting
one grapheme at a time:
<?php
function u_tolower($text=''){
// if blank, return blank (don't waste CPU cycles)
if($text==''){return '';}
// for each grapheme
$str='';
for($i=0;$i<grapheme_strlen($text);$i++){
// add to string if alpha, else as is
$char=grapheme_substr($text,$i,1);
$str.=(IntlChar::isalnum($char)?IntlChar::tolower($char):$char);
}
// return converted text
return $str;
}
?>
----
Server IP: 45.112.84.4
Probable Submitter: 38.142.137.34 (proxied: 14.200.20.175)
----
Manual Page -- http://php.net/manual/en/intlchar.tolower.php
Edit -- https://master.php.net/note/edit/124660
Del: integrated -- https://master.php.net/note/delete/124660/integrated
Del: useless -- https://master.php.net/note/delete/124660/useless
Del: bad code -- https://master.php.net/note/delete/124660/bad+code
Del: spam -- https://master.php.net/note/delete/124660/spam
Del: non-english -- https://master.php.net/note/delete/124660/non-english
Del: in docs -- https://master.php.net/note/delete/124660/in+docs
Del: other reasons-- https://master.php.net/note/delete/124660
Reject -- https://master.php.net/note/reject/124660
Search -- https://master.php.net/manage/user-notes.php