PHP ucwords() Function

PHP ucwords() Function

The ucwords() function in PHP converts the first character of each word in the specified string to uppercase. It is a binary-safe function.

The related function are as follows:

  • ucfirst()
  • lcfirst()
  • strtoupper()
  • strtolower()

Syntax

ucwords ( string $str [, string $delimiters ] )

Parameter

str(required)- This parameter represents the input string.

delimeters(optional)- This parameter contains the word separator characters i.e ‘\t, \r, \n, \f, \v’.

Return

This parameter returns a string with the first character of each word in the specified string capitalized if that character is alphabetic.

Example 1

 

Output

Actual String: pHP is an easy language to learn.
After ucwords() function...
New string: PHP Is An Easy Language To Learn. 

Example 2

 

Output

After ucwords() Function...
 The Places To Visit In India Are As Follow: 
 Taj mahal
 Lotus temple
 Akshardham temple 

Example 3

 

Output

Original string: HELLO WORLD! NICE TO MEET YOU
After ucwords() Function...
New String: Hello World! Nice To Meet You 

Example 4

 

Output

Original string: hello|world!|how|are|you|today?
After ucwords() Function...
New String: Hello|World!|How|Are|You|Today? 

Related Topics

PHP substr_compare() Function

PHP substr_compare() Function The substr_compare() function in PHP compares two strings from a specified start position. It is a binary-safe and optionally case-sensitive function. Syntax substr_compare ( string $main_str , string $str , int $offset [, int $length [, bool$case_insensitivity]] )  Parameter main_str(required)- This parameter specifies the first string to compare. str(required)- This parameter...

1 minute read.

PHP str_split() Function

PHP str_split() Function The str_split() function in PHP splits a string into an array. String str_split ( string $string [, int $split_length = 1 ] ) Parameter string(required)- This parameter represents the input string. split_length(optional)- This parameter signifies the maximum length of the chunk. The default value is 1. Return This function...

2 minutes read.

PHP $ and $$ Variables

PHP $var variable is a normal variable that stores any value. PHP $$var variable is a reference variable that stores the value of$var inside it. Let us take an example. Example 1 <?php $x =...

1 minute read.

PHP str_getcsv() Function

PHP str_getcsv() Function The str_getcsv() function in PHP parses a CSV string into an array and returns an array containing the fields read. Syntax str_getcsv ( string $input [, string $delimiter [, string $enclosure [, string$escape ]]] ) Parameter input(required)- This parameter represents the string to parse. delimiter(optional)- This parameter signifies...

1 minute read.

PHP levenshtein() Function

PHP levenshtein() Function The levenshtein() function in PHP calculates the Levenshtein distance between two strings. Syntax levenshtein ( string $str1 , string $str2 , int $cost_ins , int $cost_rep , int $cost_del )  Parameter str1(required)- This parameter signifies one of the strings being evaluated for Levenshtein distance. str2(required)- This parameter signifies one of the strings being evaluated...

1 minute read.

PHP array_merge_recursive() Function

PHP array_merge_recursive() Function The array_merge_recursive() function  in PHP merges the elements of one or arrays together and returns the resulting array. Syntax array_merge_recursive (array $array  , [ array $... ] ) Parameter array(required)- This parameter specifies the input array ….(optional)- It represents more arrays to...

1 minute read.

PHP array_key_first() function

The array_key_first () function in PHP gets the first key of an array if the specified array is not empty. Syntax array_key_first(array;$array) Parameter array(required)- This parameter signifies the input array. Return This function returns the first key of the specified...

1 minute read.

PHP strcspn() Function

PHP strcspn() Function The strcspn() function in PHP returns the number of characters (including whitespaces) found in a string before any part of the specified characters is found. It is a binary-safe function. Syntax strcspn ( string $subject , string $mask [, int $start [, int $length ]] ) Parameter subject(required)- This...

1 minute read.

PHP quoted_printable_decode() Function

PHP quoted_printable_decode() Function The quote_printable_decode() function of PHP converts a quoted-printable string to an 8 bit string. It works similar to imap_qprint(), except this one does not require the IMAP module to work. Syntax quoted_printable_decode ( string $str ) Parameter str(required)- This parameter represents the...

1 minute read.

PHP is_bool() Function

The is_bool() Function in PHP is used to  find whether a variable is a Boolean or not. It returns a Boolean value true if the parameter var is a Boolean else it returns...

1 minute read.

PHP str_ireplace() Function

PHP str_ireplace() Function The PHP str_ireplace() function in PHP replaces some characters with some other characters in a string. Syntax str_ireplace ( mixed $search , mixed  $replace , mixed $subject [, int &$count ] ) Parameter search(required)- This parameter specifies the value being searched for. replace(required)- This parameter represents the replacement value...

1 minute read.

PHP array_walk() Function

PHP array_walk() Function The array_walk() function in PHP is used to apply the user-defined callback function to each element of the array. This function returns a Boolean TRUE on success or FALSE on failure. Syntax array_walk ( array &$array , callable $callback [, mixed $userdata = NULL ] ) Parameter array(required)- This array represents...

1 minute read.

PHP nl2br() Function

PHP nl2br() Function The nl2br() function in PHP inserts HTML line breaks before all newlines in a string. Syntax nl2br ( string $string [, bool $is_xhtml] ) Parameter sting(required)- This parameter specifies the input string. is_xhtml(optional)- This parameter states whether to use XHTML compatible line breaks...

1 minute read.

How to use Date and Time in PHP

HOW TO USE DATE AND TIME IN PHP: PHP time and date function  informs us about current date and time. it can be manipulated also. How time() function works: The time() function...

2 minutes read.

PHP array_udiff() Function

PHP array_udiff() Function The array_udiff() function in PHP calculates the difference of arrays by using a callback function for data comparison. Syntax array_udiff ( array $array1 , array $array2 [, array $... ], callable $value_compare_func ) Parameter array1(required)- This array represents the first input array. array2(required)- This array represents the second input array. array3….(optional)- It...

1 minute read.

PHP substr() Function

PHP substr() Function The substr() function in PHP returns the portion of the string specified by the start and length parameters. Syntax substr ( string $string , int $start [, int $length ] )  Parameter string (required)- This parameter represents the input string. It must be one character or longer. start (required)- This parameter specifies where to start...

2 minutes read.

PHP is_integer() Function

The PHP is_integer() function in PHP is used to  find whether a variable is an integer or not. It returns a Boolean value true if the parameter var is integer else it returns...

1 minute read.

PHP array_udiff_assoc() Function

PHP array_udiff_assoc() Function The array_udiff_assoc () function in PHP computes the difference between the specified arrays with additional index check and compares the data by a callback function. It returns all the values from array1 that are not...

1 minute read.

PHP str_shuffle() Function

PHP str_shuffle() Function The str_shuffle() function in PHP randomly shuffles all the characters of the specified string. Syntax str_shuffle ( string $str ) Parameter str(required)- This parameter represents the input string to shuffle. Return This function returns the shuffled string. Example 1 ...

1 minute read.

Multiple-Inheritance in PHP

Multiple-Inheritance in PHP Multiple-Inheritance is the resources of the Object Oriented Programming Languages in which child class or subclass can inherit the resources of the multiple parent classes or superclasses. PHP does...

3 minutes read.