Skip to content

Kirby 5.0.4

$field->words()

Returns the number of words in the text

$field->words(): int

Return type

int

This method modifies the existing $field object it is applied to and returns it again.

Examples

<?= $page->text()->kirbytext() ?>

<dl class="text-stats">

  <dt>Characters</dt>
  <dd><?= $page->text()->length() ?></dd>

  <dt>Words</dt>
  <dd><?= $page->text()->words() ?></dd>

</dl>