aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/smarty/smarty/docs/designers/language-modifiers/language-modifier-count-characters.md
blob: 8fc37d7a93a78dda2a7b198458b814ebb3c1b5f7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# count_characters

This is used to count the number of characters in a variable.

## Basic usage
```smarty
{$myVar|count_characters}
```

## Parameters

| Parameter | Type    | Required | Description                                                            |
|-----------|---------|----------|------------------------------------------------------------------------|
| 1         | boolean | No       | This determines whether to include whitespace characters in the count. |

## Examples

```php
<?php

    $smarty->assign('articleTitle', 'Cold Wave Linked to Temperatures.');

```

Where template is:

```smarty
    {$articleTitle}
    {$articleTitle|count_characters}
    {$articleTitle|count_characters:true}
```

Will output:

```
    Cold Wave Linked to Temperatures.
    29
    33
```
       
See also [`count_words`](language-modifier-count-words.md),
[`count_sentences`](language-modifier-count-sentences.md) and
[`count_paragraphs`](language-modifier-count-paragraphs.md).