Unix and Linux Discussions Tagged with today |
|
Thread / Thread Starter |
Last Post |
Replies |
Views |
Forum |
|
|
|
14 |
13,810 |
Cybersecurity |
|
|
|
1 |
10,583 |
What is on Your Mind? |
|
|
|
2 |
2,673 |
UNIX for Beginners Questions & Answers |
|
|
|
2 |
18,098 |
Shell Programming and Scripting |
|
|
|
7 |
8,927 |
Shell Programming and Scripting |
|
|
|
0 |
847 |
Software Releases - RSS News |
|
|
|
5 |
16,630 |
Shell Programming and Scripting |
|
|
|
0 |
1,010 |
UNIX and Linux RSS News |
|
|
|
0 |
915 |
Software Releases - RSS News |
|
|
|
0 |
3,428 |
AIX |
|
|
|
0 |
1,676 |
UNIX and Linux RSS News |
|
|
|
2 |
3,841 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
2,817 |
Shell Programming and Scripting |
|
|
|
12 |
30,279 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
7,185 |
Shell Programming and Scripting |
|
|
|
4 |
2,712 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
3,866 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
2,752 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
3,717 |
Programming |
|
|
|
4 |
3,237 |
UNIX for Dummies Questions & Answers |
|
|
|
22 |
45,673 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
3,161 |
UNIX for Dummies Questions & Answers |
|
|
|
5 |
2,765 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
4,171 |
Programming |
|
|
|
4 |
8,707 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
3,809 |
Post Here to Contact Site Administrators and Moderators |
|
|
|
8 |
5,417 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
2,708 |
Post Here to Contact Site Administrators and Moderators |
|
|
|
1 |
3,075 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
4,292 |
Post Here to Contact Site Administrators and Moderators |
|
|
|
5 |
3,075 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
61,322 |
UNIX for Dummies Questions & Answers |
|
|
|
8 |
7,168 |
UNIX for Dummies Questions & Answers |
|
|
|
4 |
4,913 |
IP Networking |
|
|
|
13 |
84,227 |
New to Unix. Which books should I read? |
|
|
|
13 |
10,087 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
8,756 |
UNIX for Dummies Questions & Answers |
|
|
|
10 |
29,103 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
2,657 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
7,248 |
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)