str_word_count
Function • Params and return types changed in PHP 8.0
Return information about words used in a string.
str_word_count Function synopsis
str_word_count(
string $string,
int $format = 0,
?string $characters = null
): array|int
Parameters
$string
Typestring
The string
$format
OptionalTypeintDefault value0
Specify the return value of this function. The current supported values are:
$characters
OptionalType?stringDefault valuenull
A list of additional characters which will be considered as 'word'
Return value
Typearray|int
Returns an array or an integer, depending on the
$format chosen.
Changes to the str_word_count Function
PHP 8.0
- Return type added:
array|int - Parameter name of parameter #1 changed:
$strto$string - Parameter type added for parameter #1 (
$string):string - Parameter type added for parameter #2 (
$format):int - Parameter default value added for position #2 (
$format):0 - Parameter name of parameter #3 changed:
$charlistto$characters - Parameter type added for parameter #3 (
$characters):?string - Parameter default value added for position #3 (
$characters):null
str_word_count(
- $str,
+ string $string,
- $format,
+ int $format = 0,
- $charlist
+ ?string $characters = null
- )
+ ): array|int str_word_count Function Availability
str_word_count Function Availability| PHP Version | Availability |
|---|---|
| PHP 8.6Upcoming Release | Yes |
| PHP 8.5Supported (Latest) | Yes |
| PHP 8.4Supported | Yes |
| PHP 8.3Security-Fixes Only | Yes |
| PHP 8.2Security-Fixes Only | Yes |
| PHP 8.1Unsupported | Yes |
| PHP 8.0Unsupported | Yes |
| PHP 7.4Unsupported | Yes |
| PHP 7.3Unsupported | Yes |
| PHP 7.2Unsupported | Yes |
| PHP 7.1Unsupported | Yes |
| PHP 7.0Unsupported | Yes |
| PHP 5.6Unsupported | Yes |
| PHP 5.5Unsupported | Yes |
| PHP 5.4Unsupported | Yes |
| PHP 5.3Unsupported | Yes |