downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

mb_strtoupper> <mb_strstr
Last updated: Fri, 14 Aug 2009

view this page in

mb_strtolower

(PHP 4 >= 4.3.0, PHP 5)

mb_strtolowerMet tous les caractères en minuscules

Description

string mb_strtolower ( string $str [, string $encoding= mb_internal_encoding() ] )

Retourne la chaîne str après avoir converti tous les caractères alphabétiques en minuscules.

Liste de paramètres

str

La chaîne à mettre en minuscule.

encoding

Le paramètre encoding est l'encodage des caractères. S'il est omis, l'encodage de caractres interne sera utilisé.

Valeurs de retour

Retourne la chaîne str dont tous les caractères alphabétiques ont été mis en minuscule.

Unicode

Pour plus d'informations sur les propriétés de l'Unicode, voyez » http://www.unicode.org/unicode/reports/tr21/.

Contrairement à strtolower(), le concept de caractère 'alphabétique' est déterminé par les propriétés Unicode. De ce fait, le comportement de cette fonction n'est pas modifié par les configurations locales, et elle peut convertir tout les caractères qui sont considérés comme alphabétiques comme le c cédille (Ç).

Exemples

Exemple #1 Exemple avec mb_strtolower()

<?php
$str 
"Marie A Un Petit Agneau Et Elle L'Aime BEAUCOUP.";
$str mb_strtolower($str);
echo 
$str// marie a un petit agneau et elle l'aime beaucoup
?>

Voir aussi



mb_strtoupper> <mb_strstr
Last updated: Fri, 14 Aug 2009
 
add a note add a note User Contributed Notes
mb_strtolower
pozmu at the same as user name dot net
21-Jan-2008 04:55
btherl at yahoo dot com dot au - it also corrupt other characters, like Polish national characters (which can be found also in iso-8859-2 encoding).

So if your locale != charset used in php always specify charset as second argument:

<? echo mb_strtolower("WSTĘP","UTF-8"); ?>
Philipp H
01-Nov-2007 07:11
Note that mb_strtolower() is very SLOW, if you have a database connection, you may want to use it to convert your strings to lower case. Even latin1/9 (iso-8859-1/15) and other encodings are possible.

Have a look at my simple benchmark:

<?php

$text
= "Lörem ipßüm dölör ßit ämet, cönßectetüer ädipißcing elit. Sed ligülä. Präeßent jüßtö tellüß, grävidä eü, tempüß ä, mättiß nön, örci. Näm qüiß lörem. Näm äliqüet elit ßed elit. Phäßellüß venenätiß jüßtö eget enim. Dönec nißl. Pröin mättiß venenätiß jüßtö. Sed äliqüäm pörtä örci. Cräß elit nißl, cönvälliß qüiß, tincidünt ät, vehicülä äccümßän, ödiö. Sed möleßtie. Etiäm mölliß feügiät elit. Veßtibülüm änte ipßüm primiß in fäücibüß örci lüctüß et ültriceß pößüere cübiliä Cüräe; Mäecenäß nön nüllä.";

// mb_strtolower()
$timeMB = microtime(true);    
             
    for(
$i=0;$i<30000;$i++)
       
$lower = mb_strtolower("$text/no-cache-$i");

$timeMB = microtime(true) - $timeMB;

// MySQL lower()
$timeSQL = microtime(true);   

   
mysql_query("set names latin1");              
    for(
$i=0;$i<30000;$i++) {
       
$r = mysql_fetch_row(mysql_query("select lower('$text/no-cache-$i')"));
       
$lower = $r[0];
    }

$timeSQL = microtime(true) - $timeSQL;

echo
"mb: ".sprintf("%.5f",$timeMB)." sek.<br />";
echo
"sql: ".sprintf("%.5f",$timeSQL)." sek.<br />";

// Result on my notebook:
// mb: 11.50642 sek.
// sql: 5.44143 sek.

?>
btherl at yahoo dot com dot au
16-Nov-2005 06:12
If you use this function on a unicode string without telling PHP that it is unicode, then you will corrupt your string.  In particular, the uppercase 'A' with tilde, common in 2-byte UTF-8 characters, is converted to lowercase 'a' with tilde.

This can be handled correctly by:
$str = mb_strtolower($str, mb_detect_encoding($str));

Or if you know your data is UTF-8, just use the string "UTF-8" as the second argument.

You should check also that mb_detect_encoding() is checking the encodings you want it to check, and is detecting the correct encodings.

mb_strtoupper> <mb_strstr
Last updated: Fri, 14 Aug 2009
 
 
show source | credits | sitemap | contact | advertising | mirror sites