mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
adding example (user note)
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@142762 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
d5d07fcec5
commit
719aed0d1c
1 changed files with 41 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.4 $ -->
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<!-- splitted from ./en/functions/strings.xml, last change in rev 1.4 -->
|
||||
<refentry id="function.count-chars">
|
||||
<refnamediv>
|
||||
|
@ -18,7 +18,7 @@
|
|||
<para>
|
||||
Counts the number of occurrences of every byte-value (0..255) in
|
||||
<parameter>string</parameter> and returns it in various ways.
|
||||
The optional parameter <parameter>Mode</parameter> default to
|
||||
The optional parameter <parameter>mode</parameter> default to
|
||||
0. Depending on <parameter>mode</parameter>
|
||||
<function>count_chars</function> returns one of the following:
|
||||
<itemizedlist>
|
||||
|
@ -52,6 +52,45 @@
|
|||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title><function>count_chars</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$data = "Two Ts and one F.";
|
||||
|
||||
$result = count_chars($data, 0);
|
||||
|
||||
for ($i=0; $i < count($result); $i++) {
|
||||
if ($result[$i] != 0)
|
||||
echo "There were $result[$i] instance(s) of \"" , chr($i) , "\" in the string.\n";
|
||||
}
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
This will output :
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
There were 4 instance(s) of " " in the string.
|
||||
There were 1 instance(s) of "." in the string.
|
||||
There were 1 instance(s) of "F" in the string.
|
||||
There were 2 instance(s) of "T" in the string.
|
||||
There were 1 instance(s) of "a" in the string.
|
||||
There were 1 instance(s) of "d" in the string.
|
||||
There were 1 instance(s) of "e" in the string.
|
||||
There were 2 instance(s) of "n" in the string.
|
||||
There were 2 instance(s) of "o" in the string.
|
||||
There were 1 instance(s) of "s" in the string.
|
||||
There were 1 instance(s) of "w" in the string.
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</para>
|
||||
<simpara>
|
||||
See also <function>strpos</function> and
|
||||
<function>substr_count</function>.
|
||||
|
|
Loading…
Reference in a new issue