cvs: phpdoc /en/functions array.xml

From: Date: Thu, 20 Dec 2001 20:23:48 +0000
Subject: cvs: phpdoc /en/functions array.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969340170@lists.php.net to get a copy of this message
jimw Thu Dec 20 15:23:48 2001 EDT Modified files: /phpdoc/en/functions array.xml Log: range: provide examples of generating decrementing arrays and character ranges using array_reverse and array_map Index: phpdoc/en/functions/array.xml diff -u phpdoc/en/functions/array.xml:1.138 phpdoc/en/functions/array.xml:1.139 --- phpdoc/en/functions/array.xml:1.138 Thu Dec 20 15:14:32 2001 +++ phpdoc/en/functions/array.xml Thu Dec 20 15:23:48 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.138 $ --> +<!-- $Revision: 1.139 $ --> <reference id="ref.array"> <title>Array Functions</title> <titleabbrev>Arrays</titleabbrev> @@ -3137,9 +3137,10 @@ <function>range</function> returns an array of elements from <parameter>low</parameter> to <parameter>high</parameter>, inclusive. If low > high, the sequence will be from high to low. - <example> - <title><function>range</function> examples</title> - <programlisting role="php"> + </para> + <example> + <title><function>range</function> examples</title> + <programlisting role="php"> <![CDATA[ foreach(range(0, 9) as $number) { echo $number; @@ -3151,15 +3152,30 @@ echo $letter; } ]]> - </programlisting> - </example> - </para> + </programlisting> + </example> <note> <para> Prior to version 4.1.0 the <function>range</function> function only generated incrementing integer arrays. Support for character sequences and decrementing arrays was added in 4.1.0. </para> + <example> + <title>Simulating decrementing ranges and character sequences</title> + <programlisting role="php"> +<![CDATA[ +# array_reverse can be used to flip the order of a range +foreach(array_reverse(range(0,9)) as $number) { + echo $number; +} + +# array_map() can be used to turn integers into characters using chr() +foreach(array_map('chr', range(ord('a'),ord('z'))) as $character) { + echo $character; +} +]]> + </programlisting> + </example> </note> <para> See <function>shuffle</function> for another example of its use.

« previous php.doc (#969340170) next »