mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-26 22:08:55 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@181998 c90b9560-bf6c-de11-be94-00142212c4b1
215 lines
5.1 KiB
XML
215 lines
5.1 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
||
<!-- $Revision: 1.7 $ -->
|
||
<refentry id="function.str-word-count">
|
||
<refnamediv>
|
||
<refname>str_word_count</refname>
|
||
<refpurpose>
|
||
Return information about words used in a string
|
||
</refpurpose>
|
||
</refnamediv>
|
||
<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>.
|
||
If the optional <parameter>format</parameter> is not specified, then
|
||
the return value will be an integer representing the number of words
|
||
found. In the event the <parameter>format</parameter> is specified, the return
|
||
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.
|
||
</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>A <function>str_word_count</function> example</title>
|
||
<programlisting role="php">
|
||
<![CDATA[
|
||
<?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, '<27><><EFBFBD><EFBFBD>3'));
|
||
|
||
echo str_word_count($str);
|
||
|
||
?>
|
||
]]>
|
||
</programlisting>
|
||
&example.outputs;
|
||
<screen>
|
||
<![CDATA[
|
||
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
|
||
]]>
|
||
</screen>
|
||
</example>
|
||
</para>
|
||
</refsect1>
|
||
|
||
<refsect1 role="seealso">
|
||
&reftitle.seealso;
|
||
<para>
|
||
<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>
|
||
|
||
<!-- Keep this comment at the end of the file
|
||
Local variables:
|
||
mode: sgml
|
||
sgml-omittag:t
|
||
sgml-shorttag:t
|
||
sgml-minimize-attributes:nil
|
||
sgml-always-quote-attributes:t
|
||
sgml-indent-step:1
|
||
sgml-indent-data:t
|
||
indent-tabs-mode:nil
|
||
sgml-parent-document:nil
|
||
sgml-default-dtd-file:"../../../../manual.ced"
|
||
sgml-exposed-tags:nil
|
||
sgml-local-catalogs:nil
|
||
sgml-local-ecat-files:nil
|
||
End:
|
||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||
vim: et tw=78 syn=sgml
|
||
vi: ts=1 sw=1
|
||
-->
|