Signatur
str_word_count(string $string, int $format = 0, ?string $characters = null): array|int
Beschreibung
Mit $format = 0 nur die Anzahl, 1 ein Array mit Wörtern, 2 mit Position → Wort.
Parameter
| Name | Typ | Default | Beschreibung |
|---|---|---|---|
| $string Pflicht | string | — | Eingabe. |
| $format | int | 0 | 0/1/2 — siehe Beschreibung. |
| $characters | ?string | null | Zusätzliche Zeichen, die als Buchstaben gelten. |
Rückgabewert
Typ
array|int
Beschreibung
Anzahl oder Wort-Array.
Beispiele
Anzahl
<?php
echo str_word_count('Hallo Welt Programmierung'); // 3