PHP String ucwords() Function17 Mar 2025 | 2 min read The ucwords() is an in-built function of PHP, which is used to convert the first character of each word to uppercase in a string. The ucwords() is supported by the PHP 4 and above versions. It takes a string as an input and converts the first character of each word of the string to uppercase. The other characters of the string remain the same. Note: The ucwords() is a binary-safe function.There are some other functions in PHP which are similar to the ucwords() function: Related functions
SyntaxThe syntax of the ucwords() function is given below that accepts two parameters. The ucwords() returns the converted string whose first character of each word is converted to uppercase. Parameters$string (required) - It is a mandatory parameter of this function, which specifies the input string that needs to be converted. $separator (optional) - It is an optional parameter of this function, which contains the words separator characters. It specifies a character that uses a separator for the words in the input string. By default these separator characters are:
Return ValuesThe ucwords() function returns the modified string, where the first character of each word in a string is converted to uppercase. Changelog
ExamplesThere are some examples given, through which we can learn the working of the ucwords() function. Let's see the below examples- Example 1 Output: Hello, My Name Is Lovyansh. Example 2 Output: Before: Good morning! everyone. After: Good Morning! Everyone. Example 3 Output: In the above example, we have used "|" as a separator, which needs to be passed in ucwords() while modifying the string. Good|morning!|everyone. Good|Morning!|Everyone. Note: Doller $ symbol cannot be used as a separator, because $ is used before every variable in PHP. So, the program will generate an error "variable not found."Next TopicPHP String Functions |
function in PHP The is a case-insensitive, built-in function of PHP. It compares two strings for the first n characters. This function is similar to the strcasecmp() function with a difference. In , we can specify the number of characters from both the strings for...
3 min read
PHP string md5_file() Function PHP string md5_file() function is in-built important function. It is used to calculate the MD5 hash of a file. It uses the RSA Data Security. It returns the md5 hash on success, or FALSE on failure. Syntax: md5_file(file,raw); Parameter Description Required/Optional File Specify the file to be calculated. Required Raw Specify the Boolean...
1 min read
PHP string Function The function is predefined PHP string function. It is used to calculate the SHA-1 hash of a file. It uses he US secure Hash Algorithm 1 and calculate the ha1 hash US secure Hash Algorithm 1. The hash is a 40 character hexadecimal...
1 min read
PHP Hebrev() Function PHP is string function, which is used to convert Hebrew text from right to left or left to right visual text. Syntax: hebrev(string,maxcharline) ; Parameter Description Required/Optional string A Hebrew text. required maxcharline Specify maximum character for each line. optional Example 1 <?php echo hebrev("? ???? ?????"); ?> Output: ??????? ?????? ??? TopicPHP String ...
1 min read
PHP Function The strops() is in-built function of PHP. It is used to find the position of the first occurrence of a string inside another string or substring in a string. Syntax: int strpos ( string $haystack , mixed $needle [, int $offset = 0 ] ); Parameter Description Required/Optional string Specify the...
2 min read
PHP implode() is a string function, which joins the array elements in a string. It is a binary-safe function. In implode() function, parameters can be passed in any order. The implode() function works same as the join() function and returns a string created from the elements...
2 min read
PHP Function PHP function is used to convert string value of ASSCII characters to hexadecimal value. Syntax: string bin2hex ( string $str ) Parameter Description Required/Optional string The string to be converted Required Example 1 <?php $str ="Hello World!"; echo "Your ASCII character is: ".$str; echo "<br>"."By using '' Method your hexadecimal value is: ".bin2hex($str); ?> Output: Your ASCII...
1 min read
PHP String function The function is an in-built function of PHP. It is a case-sensitive function which finds the first occurrence of a string. The is mainly used to search the first occurrence of a string inside another string and displays some part of...
3 min read
PHP Function The function in inbuilt function of PHP. It is used to find the position of the last occurrence of a string. This function returns all characters from this position to the end of the string or FALSE if the character is not found. Note: The...
1 min read
PHP Function PHP function is predefined string PHP function , which is used to decode a uuencoded string. It returns the decoded data as a string. Syntax: string convert_uudecode ( string $data ); Parameter Description Required/Optional string The uuencoded string to decode Required Example 1 <?php $str ="*:F%V851P;VEN=``` ` "; // javatpoint echo "Your Decode string is...
1 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India