Jump to: navigation, search

Php ucfirst

From w3cyberlearnings

Contents

PHP function ucfirst

This function converts the first character of a given string to uppercase. Uppercase first.

Syntax ucfirst

  • string: string input to convert for the first character to uppercase.
ucfirst(string);

Example 1

<?php

$str = "excellent work!";
echo ucfirst($str);
?>

Output

Excellent work!

Example 2

<?php

$str="JANNI WEEK";

echo ucfirst(strtolower($str));

?>

Output

Janni week

Example 3

<?php

$name = array('   bob maat ', 'janny', 'paul david', ' jeson');

foreach ($name as $n) {
	echo ucfirst(trim($n)) . '<br/>';
}
?>

Output

Bob maat
Janny
Paul david
Jeson

Related Functions


Navigation
Web
SQL
MISC
References