mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 16:38:54 +00:00
switch to new style and document new charlist parameter
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@181998 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
e113ce75a0
commit
ed86408513
1 changed files with 130 additions and 40 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.6 $ -->
|
||||
<!-- $Revision: 1.7 $ -->
|
||||
<refentry id="function.str-word-count">
|
||||
<refnamediv>
|
||||
<refname>str_word_count</refname>
|
||||
|
@ -7,12 +7,13 @@
|
|||
Return information about words used in a string
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<type>mixed</type><methodname>str_word_count</methodname>
|
||||
<methodparam><type>string</type><parameter>string</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>int</type><parameter>format</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>string</type><parameter>charlist</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Counts the number of words inside <parameter>string</parameter>.
|
||||
|
@ -22,83 +23,172 @@
|
|||
value will be an array, content of which is dependent on the
|
||||
<parameter>format</parameter>. The possible value for the
|
||||
<parameter>format</parameter> and the resultant outputs are listed below.
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<simpara>
|
||||
1 - returns an array containing all the words found inside the
|
||||
<parameter>string</parameter>.
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
2 - returns an associative array, where the key is the numeric
|
||||
position of the word inside the <parameter>string</parameter> and
|
||||
the value is the actual word itself.
|
||||
</simpara>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<para>
|
||||
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.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>string</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The string
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><parameter>format</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specify the return value of this function. The current supported values
|
||||
are:
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<simpara>
|
||||
0 - returns the number of words found
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
1 - returns an array containing all the words found inside the
|
||||
<parameter>string</parameter>
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
2 - returns an associative array, where the key is the numeric
|
||||
position of the word inside the <parameter>string</parameter> and
|
||||
the value is the actual word itself
|
||||
</simpara>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><parameter>charlist</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
A list of additional characters which will be considered as 'word'
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns an array or an integer, depending on the
|
||||
<parameter>format</parameter> chosen.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="changelog">
|
||||
&reftitle.changelog;
|
||||
<para>
|
||||
<informaltable>
|
||||
<tgroup cols="2">
|
||||
<thead>
|
||||
<row>
|
||||
<entry>&Version;</entry>
|
||||
<entry>&Description;</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>5.1.0</entry>
|
||||
<entry>
|
||||
Added the <parameter>charlist</parameter> parameter
|
||||
</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title>Example uses for <function>str_word_count</function></title>
|
||||
<title>A <function>str_word_count</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$str = "Hello friend, you're
|
||||
looking good today!";
|
||||
$str = "Hello fri3nd, you're
|
||||
looking good today!";
|
||||
|
||||
$a = str_word_count($str, 1);
|
||||
$b = str_word_count($str, 2);
|
||||
$c = str_word_count($str);
|
||||
print_r(str_word_count($str, 1));
|
||||
print_r(str_word_count($str, 2));
|
||||
print_r(str_word_count($str, 1, 'àáãç3'));
|
||||
|
||||
echo str_word_count($str);
|
||||
|
||||
print_r($a);
|
||||
print_r($b);
|
||||
echo $c;
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
|
||||
Array
|
||||
(
|
||||
[0] => Hello
|
||||
[1] => friend
|
||||
[2] => you're
|
||||
[3] => looking
|
||||
[4] => good
|
||||
[5] => today
|
||||
[1] => fri
|
||||
[2] => nd
|
||||
[3] => you're
|
||||
[4] => looking
|
||||
[5] => good
|
||||
[6] => today
|
||||
)
|
||||
|
||||
Array
|
||||
(
|
||||
[0] => Hello
|
||||
[6] => friend
|
||||
[6] => fri
|
||||
[10] => nd
|
||||
[14] => you're
|
||||
[29] => looking
|
||||
[46] => good
|
||||
[51] => today
|
||||
)
|
||||
|
||||
6
|
||||
Array
|
||||
(
|
||||
[0] => Hello
|
||||
[1] => fri3nd
|
||||
[2] => you're
|
||||
[3] => looking
|
||||
[4] => good
|
||||
[5] => today
|
||||
)
|
||||
|
||||
7
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
See also <function>explode</function>,
|
||||
<function>preg_split</function>,
|
||||
<function>split</function>,
|
||||
<function>count_chars</function>, and
|
||||
<function>substr_count</function>.
|
||||
<simplelist>
|
||||
<member><function>explode</function></member>
|
||||
<member><function>preg_split</function></member>
|
||||
<member><function>split</function></member>
|
||||
<member><function>count_chars</function></member>
|
||||
<member><function>substr_count</function></member>
|
||||
</simplelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
|
Loading…
Reference in a new issue