Jump to: navigation, search

Php strtoupper

From w3cyberlearnings

Contents

PHP function strtoupper

This function converts a string to uppercase. For lowercase check php strtoupper

Syntax strtoupper

  • string: string input
strtoupper(string)

Example 1

<?php

$str ="Good old day.";
echo strtoupper($str);
?>

Output

GOOD OLD DAY.

Example 2

<?php
<?php

$my_list = array('hi',
	 'work of art',
	 'famous article',
	 'girl of the night', 
	 'dark size of human');

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

print_r($my_list);
?>

Output

Array ( 
[0] => HI 
[1] => WORK OF ART 
[2] => FAMOUS ARTICLE 
[3] => GIRL OF THE NIGHT 
[4] => DARK SIZE OF HUMAN )

Example 3

<?php

$my_list = array('give up',
	 'never give up',
	 'do not give up',
	 'php project',
	 'lost city');
$my_list_lower = array_map('strtoupper', $my_list);

print_r($my_list_lower);
?>

Output

Array ( 
[0] => GIVE UP 
[1] => NEVER GIVE UP 
[2] => DO NOT GIVE UP 
[3] => PHP PROJECT 
[4] => LOST CITY )

Related Functions


Navigation
Web
SQL
MISC
References