Unix and Linux Discussions Tagged with today |
|
Thread / Thread Starter |
Last Post |
Replies |
Views |
Forum |
|
|
|
14 |
13,965 |
Cybersecurity |
|
|
|
1 |
10,606 |
What is on Your Mind? |
|
|
|
2 |
2,685 |
UNIX for Beginners Questions & Answers |
|
|
|
2 |
18,106 |
Shell Programming and Scripting |
|
|
|
7 |
8,930 |
Shell Programming and Scripting |
|
|
|
0 |
850 |
Software Releases - RSS News |
|
|
|
5 |
16,631 |
Shell Programming and Scripting |
|
|
|
0 |
1,013 |
UNIX and Linux RSS News |
|
|
|
0 |
915 |
Software Releases - RSS News |
|
|
|
0 |
3,439 |
AIX |
|
|
|
0 |
1,677 |
UNIX and Linux RSS News |
|
|
|
2 |
3,843 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
2,820 |
Shell Programming and Scripting |
|
|
|
12 |
30,317 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
7,191 |
Shell Programming and Scripting |
|
|
|
4 |
2,715 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
3,870 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
2,759 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
3,724 |
Programming |
|
|
|
4 |
3,241 |
UNIX for Dummies Questions & Answers |
|
|
|
22 |
45,714 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
3,167 |
UNIX for Dummies Questions & Answers |
|
|
|
5 |
2,770 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
4,173 |
Programming |
|
|
|
4 |
8,716 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
3,817 |
Post Here to Contact Site Administrators and Moderators |
|
|
|
8 |
5,431 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
2,710 |
Post Here to Contact Site Administrators and Moderators |
|
|
|
1 |
3,083 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
4,296 |
Post Here to Contact Site Administrators and Moderators |
|
|
|
5 |
3,078 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
61,335 |
UNIX for Dummies Questions & Answers |
|
|
|
8 |
7,186 |
UNIX for Dummies Questions & Answers |
|
|
|
4 |
4,931 |
IP Networking |
|
|
|
13 |
84,320 |
New to Unix. Which books should I read? |
|
|
|
13 |
10,108 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
8,778 |
UNIX for Dummies Questions & Answers |
|
|
|
10 |
29,114 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
2,666 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
7,262 |
UNIX for Dummies Questions & Answers |
STR_WORD_COUNT(3) 1 STR_WORD_COUNT(3)
str_word_count - Return information about words used in a string
SYNOPSIS
mixed str_word_count (string $string, [int $format], [string $charlist])
DESCRIPTION
Counts the number of words inside $string. If the optional $format is not specified, then the return value will be an integer representing
the number of words found. In the event the $format is specified, the return value will be an array, content of which is dependent on the
$format. The possible value for the $format and the resultant outputs are listed below.
For the purpose of this function, 'word' is defined as a locale dependent string containing alphabetic characters, which also may contain,
but not start with "'" and "-" characters.
PARAMETERS
o $string
- The string
o $format
- Specify the return value of this function. The current supported values are:
o 0 - returns the number of words found
o 1 - returns an array containing all the words found inside the $string
o 2 - returns an associative array, where the key is the numeric position of the word inside the $string and the value is the
actual word itself
o $charlist
- A list of additional characters which will be considered as 'word'
RETURN VALUES
Returns an array or an integer, depending on the $format chosen.
CHANGELOG
+--------+--------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+--------------------------------+
| 5.1.0 | |
| | |
| | Added the $charlist parameter |
| | |
+--------+--------------------------------+
EXAMPLES
Example #1
A str_word_count(3) example
<?php
$str = "Hello fri3nd, you're
looking good today!";
print_r(str_word_count($str, 1));
print_r(str_word_count($str, 2));
print_r(str_word_count($str, 1, 'aaac3'));
echo str_word_count($str);
?>
The above example will output:
Array
(
[0] => Hello
[1] => fri
[2] => nd
[3] => you're
[4] => looking
[5] => good
[6] => today
)
Array
(
[0] => Hello
[6] => fri
[10] => nd
[14] => you're
[29] => looking
[46] => good
[51] => today
)
Array
(
[0] => Hello
[1] => fri3nd
[2] => you're
[3] => looking
[4] => good
[5] => today
)
7
SEE ALSO
explode(3), preg_split(3), split(3), count_chars(3), substr_count(3).
PHP Documentation Group STR_WORD_COUNT(3)