mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 08:58:56 +00:00
Clarify the feature of "character sequences", and caution that numeric strings
are seen as strings and not integers prior to PHP 4.3.3, so used as character sequences. This documents bug #24420 git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@132976 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
b01743266b
commit
fa4f1efb88
1 changed files with 17 additions and 7 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.8 $ -->
|
||||
<!-- $Revision: 1.9 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
|
||||
<refentry id="function.range">
|
||||
<refnamediv>
|
||||
|
@ -39,8 +39,8 @@
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
// array(0,1,2,3,4,5,6,7,8,9)
|
||||
foreach(range(0, 9) as $number) {
|
||||
// array(0,1,2,3,4,5,6,7,8,9,10,11,12)
|
||||
foreach(range(0, 12) as $number) {
|
||||
echo $number;
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ foreach(range(0, 100, 10) as $number) {
|
|||
echo $number;
|
||||
}
|
||||
|
||||
// Use of characters introduced in 4.1.0
|
||||
// Use of character sequences introduced in 4.1.0
|
||||
// array('a','b','c','d','e','f','g','h','i');
|
||||
foreach(range('a', 'i') as $letter) {
|
||||
echo $letter;
|
||||
|
@ -66,11 +66,21 @@ foreach(range('c', 'a') as $letter) {
|
|||
</para>
|
||||
<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.
|
||||
Prior to PHP version 4.1.0, <function>range</function> only generated
|
||||
incrementing integer arrays. Support for character sequences and
|
||||
decrementing arrays was added in 4.1.0. Character sequence values
|
||||
are limited to a length of one. If a length greater than one is
|
||||
entered, only the first character is used.
|
||||
</para>
|
||||
</note>
|
||||
<caution>
|
||||
<para>
|
||||
In PHP versions 4.1.0 through 4.3.2, <function>range</function> sees
|
||||
numeric strings as strings and not integers. Instead, they will be
|
||||
used for character sequences. For example, <literal>"4242"</literal>
|
||||
is treated as <literal>"4"</literal>.
|
||||
</para>
|
||||
</caution>
|
||||
<para>
|
||||
See also <function>shuffle</function> and
|
||||
<link linkend="control-structures.foreach">foreach</link>.
|
||||
|
|
Loading…
Reference in a new issue