mirror of
https://github.com/php/doc-ja.git
synced 2026-03-25 23:52:16 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/ja/trunk@188219 c90b9560-bf6c-de11-be94-00142212c4b1
109 lines
3.4 KiB
XML
109 lines
3.4 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision: 1.6 $ -->
|
|
<!-- EN-Revision: 1.16 Maintainer: hirokawa Status: ready -->
|
|
<!-- CREDITS: shimooka -->
|
|
<refentry id="function.range">
|
|
<refnamediv>
|
|
<refname>range</refname>
|
|
<refpurpose>
|
|
ある範囲の整数を有する配列を作成する
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>説明</title>
|
|
<methodsynopsis>
|
|
<type>array</type><methodname>range</methodname>
|
|
<methodparam><type>mixed</type><parameter>low</parameter></methodparam>
|
|
<methodparam><type>mixed</type><parameter>high</parameter></methodparam>
|
|
<methodparam choice="opt"><type>number</type><parameter>step</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>range</function>は、<parameter>low</parameter>から
|
|
<parameter>high</parameter>までの整数の配列を返します。
|
|
low > highの場合、順番はhighからlowとなります。
|
|
</para>
|
|
<note>
|
|
<title>新しい引数</title>
|
|
<simpara>
|
|
オプションの<parameter>step</parameter>引数はPHP5.0.0で追加されました。
|
|
</simpara>
|
|
</note>
|
|
<para>
|
|
<parameter>step</parameter>が指定されている場合、それは
|
|
要素毎の増加数となります。<parameter>step</parameter>は正の数で
|
|
あるべきです。デフォルトは1です。
|
|
</para>
|
|
<example>
|
|
<title><function>range</function>の例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
// array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
|
|
foreach (range(0, 12) as $number) {
|
|
echo $number;
|
|
}
|
|
|
|
// step引数はPHP5.0.0以上で使用できます
|
|
// array(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100)
|
|
foreach (range(0, 100, 10) as $number) {
|
|
echo $number;
|
|
}
|
|
|
|
// 文字列シーケンスはPHP4.1.0以降で使用できます
|
|
// array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i');
|
|
foreach (range('a', 'i') as $letter) {
|
|
echo $letter;
|
|
}
|
|
// array('c', 'b', 'a');
|
|
foreach (range('c', 'a') as $letter) {
|
|
echo $letter;
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
<note>
|
|
<para>
|
|
4.1.0より前のバージョンでは、<function>range</function>関数は、
|
|
昇順の整数配列のみを生成しました。文字シーケンス及び降順の配列
|
|
のサポートが4.1.0で追加されました。
|
|
</para>
|
|
</note>
|
|
<caution>
|
|
<para>
|
|
PHP4.1.0から4.3.2までは、<function>range</function>は
|
|
数値文字を文字(string)として認識し、数値(integer)としては認識しません。
|
|
その代わり、文字列シーケンスが使用されます。例えば、
|
|
<literal>"4242"</literal>は<literal>"4"</literal>として扱われます。
|
|
</para>
|
|
</caution>
|
|
<para>
|
|
<function>shuffle</function>,
|
|
<function>array_fill</function>,
|
|
<link linkend="control-structures.foreach">foreach</link>
|
|
も参照してください。
|
|
</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
|
|
-->
|