Jump to: navigation, search

Php strtolower

From w3cyberlearnings

Contents

PHP function strtolower

This function converts a string to lowercase.

Syntax strtolower

  • string: Input string
strtolower(string);

Example 1

<?php
$str ="Hello World!";
echo strtolower($str);
?>

Output

hello world!

Example 2

  • Convert a list of uppercase within array to all lower case.
<?php

$my_list = array('JOIN US',
	 'Work HARDER',
	 'FISH AND COOK',
	 'Go To SLEEP', 'CRAZY PARTY');
$my_list_lower = array_map('strtolower', $my_list);

print_r($my_list_lower);
?>

Output

Array
(
    [0] => join us
    [1] => work harder
    [2] => fish and cook
    [3] => go to sleep
    [4] => crazy party
)

Example 3

<?php

$my_list = array('JOIN US',
	 'Work HARDER',
	 'FISH AND COOK',
	 'Go To SLEEP', 'CRAZY PARTY');

foreach ($my_list as &$value) {
	$value = strtolower($value);
}

print_r($my_list);
?>

Output

Array
(
    [0] => join us
    [1] => work harder
    [2] => fish and cook
    [3] => go to sleep
    [4] => crazy party
)

Related Functions


Navigation
Web
SQL
MISC
References