Unix and Linux Discussions Tagged with today |
|
Thread / Thread Starter |
Last Post |
Replies |
Views |
Forum |
|
|
|
14 |
13,502 |
Cybersecurity |
|
|
|
1 |
10,538 |
What is on Your Mind? |
|
|
|
2 |
2,638 |
UNIX for Beginners Questions & Answers |
|
|
|
2 |
18,084 |
Shell Programming and Scripting |
|
|
|
7 |
8,904 |
Shell Programming and Scripting |
|
|
|
0 |
841 |
Software Releases - RSS News |
|
|
|
5 |
16,626 |
Shell Programming and Scripting |
|
|
|
0 |
1,007 |
UNIX and Linux RSS News |
|
|
|
0 |
912 |
Software Releases - RSS News |
|
|
|
0 |
3,421 |
AIX |
|
|
|
0 |
1,672 |
UNIX and Linux RSS News |
|
|
|
2 |
3,832 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
2,813 |
Shell Programming and Scripting |
|
|
|
12 |
30,191 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
7,162 |
Shell Programming and Scripting |
|
|
|
4 |
2,691 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
3,858 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
2,723 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
3,696 |
Programming |
|
|
|
4 |
3,212 |
UNIX for Dummies Questions & Answers |
|
|
|
22 |
45,539 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
3,147 |
UNIX for Dummies Questions & Answers |
|
|
|
5 |
2,740 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
4,156 |
Programming |
|
|
|
4 |
8,674 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
3,789 |
Post Here to Contact Site Administrators and Moderators |
|
|
|
8 |
5,358 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
2,697 |
Post Here to Contact Site Administrators and Moderators |
|
|
|
1 |
3,048 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
4,271 |
Post Here to Contact Site Administrators and Moderators |
|
|
|
5 |
3,030 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
61,260 |
UNIX for Dummies Questions & Answers |
|
|
|
8 |
7,101 |
UNIX for Dummies Questions & Answers |
|
|
|
4 |
4,895 |
IP Networking |
|
|
|
13 |
84,118 |
New to Unix. Which books should I read? |
|
|
|
13 |
10,013 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
8,690 |
UNIX for Dummies Questions & Answers |
|
|
|
10 |
29,006 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
2,606 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
7,183 |
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)