capitalize

capitalize — This is used to capitalize the first letter of all words in a variable.

Using function

<?php
capitalize(string $value [, bool $numwords = false ] )
  • value: string to capitalize
  • numwords: whether or not to capitalize words with numbers
Note: 1st parameter is string, 2nd parameter is capitalize and 3rd parameter is true or false The 3rd parameter determines whether or not words with digits will be upper-cased
Examples:

    if $articleTitle = "next x-men film, x3, delayed."
    {$articleTitle} //normal display
    {$articleTitle|capitalize} //capitalize the each word
    {$articleTitle|capitalize:true} //true parameter, digits for upper-cased or not with words
    

The above example will output:


    next x-men film, x3, delayed.
    Next X-Men Film, x3, Delayed.
    Next X-Men Film, X3, Delayed.