cvs: phpdoc /en/reference/strings/functions count-chars.xml

From: Date: Mon, 20 Oct 2003 11:54:57 +0000
Subject: cvs: phpdoc /en/reference/strings/functions count-chars.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969356670@lists.php.net to get a copy of this message
didou Mon Oct 20 07:54:57 2003 EDT Modified files: /phpdoc/en/reference/strings/functions count-chars.xml Log: adding example (user note) Index: phpdoc/en/reference/strings/functions/count-chars.xml diff -u phpdoc/en/reference/strings/functions/count-chars.xml:1.4 phpdoc/en/reference/strings/functions/count-chars.xml:1.5 --- phpdoc/en/reference/strings/functions/count-chars.xml:1.4 Fri Nov 8 06:06:26 2002 +++ phpdoc/en/reference/strings/functions/count-chars.xml Mon Oct 20 07:54:57 2003 @@ -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> @@ -51,6 +51,45 @@ </simpara> </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

« previous php.doc (#969356670) next »