Files
smarty/docs/designers/language-modifiers/language-modifier-count-characters.md

44 lines
985 B
Markdown
Raw Normal View History

2023-02-06 14:42:31 +01:00
# count_characters
This is used to count the number of characters in a variable.
2023-02-06 14:42:31 +01:00
## Basic usage
```smarty
{$myVar|count_characters}
```
2023-02-06 14:42:31 +01:00
## Parameters
2023-02-06 14:42:31 +01:00
| Parameter | Type | Required | Description |
|-----------|---------|----------|------------------------------------------------------------------------|
| 1 | boolean | No | This determines whether to include whitespace characters in the count. |
2023-02-06 14:42:31 +01:00
## Examples
2023-02-06 14:42:31 +01:00
```php
<?php
2023-02-06 14:42:31 +01:00
$smarty->assign('articleTitle', 'Cold Wave Linked to Temperatures.');
2023-02-06 14:42:31 +01:00
```
2023-02-06 14:42:31 +01:00
Where template is:
2023-02-06 14:42:31 +01:00
```smarty
{$articleTitle}
{$articleTitle|count_characters}
{$articleTitle|count_characters:true}
2023-02-06 14:42:31 +01:00
```
Will output:
2023-02-06 14:42:31 +01:00
```
Cold Wave Linked to Temperatures.
29
33
2023-02-06 14:42:31 +01:00
```
2023-02-06 14:42:31 +01:00
See also [`count_words`](language-modifier-count-words.md),
[`count_sentences`](language-modifier-count-sentences.md) and
[`count_paragraphs`](language-modifier-count-paragraphs.md).