привести строку к нижнему регистру php
strtolower
(PHP 4, PHP 5, PHP 7, PHP 8)
strtolower — Преобразует строку в нижний регистр
Описание
Принадлежность того или иного символа к буквенным определяется с учётом текущей локали. Это означает, что, например, в используемой по умолчанию локали «C», символ Ä не будет преобразован.
Список параметров
Возвращаемые значения
Возвращает строку в нижнем регистре.
Примеры
Пример #1 Пример использования strtolower()
Примечания
Замечание: Эта функция безопасна для обработки данных в двоичной форме.
Смотрите также
User Contributed Notes 16 notes
strtolower(); doesn’t work for polish chars
for cyrillic and UTF 8 use mb_convert_case
//output is: австралия
?>
the function arraytolower will create duplicate entries since keys are case sensitive.
I prefer this method
Array
(
[test1] => asgafasdaad
[TEST2] => asddhshsdgb
[TeSt3] => asdasda@asdadadasdasdgh
)
Array
(
[test1] => asgafasdaad
[test2] => asddhshsdgb
[test3] => asdasda@asdadadasdasdgh
)
echo fullLower ( «Ã É Ò Õ ÚÙÛ» );
//results ã é ò õ úùû
//adapted from fullUpper on strtoupper manual
?>
When you’re not sure, how the current locale is set, you might find the following function useful. It’s strtolower for utf8-formatted text:
If you’re considering using the below unhtmlentities function from phpContrib, I would suggest this one as an alternative:
There’s a ucfirst «function» to make the first character uppercase, but there’s no «lcfirst» function to make the first character lowercase. Here’s my own code to accomplish this.
I found this particularly useful for generating XML nodes with the Reflection class.
Heres a small function I wrote to stop people from submitting data that is ALL IN CAPS SO THEY CAN GET MORE ATTENTION THAT THE REST OF THE USER SUBMITTED DATA on my website 🙂 If you can make it better, by all means do so. This function splits up words delimited by a space, and makes only the first letter of each word capitalized. You can easily modify it so it’s only the very first word of the string. I’ve also added some exceptions so you don’t make things like roman numerals look like «Iii» or «Xcmii» or something.
function RemoveShouting($string)
<
$lower_exceptions = array(
«to» => «1», «a» => «1», «the» => «1», «of» => «1»
);
$higher_exceptions = array(
«I» => «1», «II» => «1», «III» => «1», «IV» => «1»,
«V» => «1», «VI» => «1», «VII» => «1», «VIII» => «1»,
«XI» => «1», «X» => «1»
);
To do case insensitive comparisons in a database, strtolower() can be a quick and dirty solution:
$Sql = «SELECT * FROM tablename WHERE LOWER(column_name) = ‘».strtolower($my_var).»‘»;
the strtolower version to support most amount of languages including russian, french and so on:
To convert an entire array to lower, I prefer this method;
If you ever need to strtolower a string with href tags on it and doesn’t want to mess with the characters inside a tag, this is for you.
?>
this:
echo loweroutsidetags(‘aALalala ‘)