PHP: ucfirst() function
Description
The ucfirst() function is used to convert the first character of a string to uppercase.
Version:
(PHP 4 and above)
Syntax:
ucfirst(string_name)
Parameter:
Name | Description | Required / Optional |
Type |
---|---|---|---|
string_name | The input string. | Required | String |
Return value:
Returns the modified string.
Value Type: String.
Pictorial Presentation
Example:
<?php
$string_name='welcome to w3resource.com';
$string_name=ucfirst($string_name);
echo $string_name;
?>
Output :
Welcome to w3resource.com
View the example in the browser
See also
PHP: Tips of the Day
Rotates the array (in left direction) by the number of shifts
Example:
<?php function tips_rotate($array, $shift = 1) { for ($i = 0; $i < $shift; $i++) { array_push($array, array_shift($array)); } return $array; } print_r(tips_rotate([1, 3, 5, 2, 4])); print_r(tips_rotate([1, 3, 5, 2, 4], 2)); ?>
Output:
Array ( [0] => 3 [1] => 5 [2] => 2 [3] => 4 [4] => 1 ) Array ( [0] => 5 [1] => 2 [2] => 4 [3] => 1 [4] => 3 )
- New Content published on w3resource:
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- React - JavaScript Library
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework