Capitalize
2 min read
Jun 2, 2026
---
title: capitalize
autoseo:
enabled: true
theme: learn2
child_type: default
admin:
children_display_order: collection
visible: true
---
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
Examples:
true or false The 3rd parameter determines whether or not words with digits will be upper-cased
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.
Leave a Comment