mirror of
https://github.com/php/doc-pt_br.git
synced 2026-04-26 01:28:05 +02:00
0ebda4eac7
git-svn-id: https://svn.php.net/repository/phpdoc/pt_BR/trunk@314030 c90b9560-bf6c-de11-be94-00142212c4b1
176 lines
4.7 KiB
XML
176 lines
4.7 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- EN-Revision: n/a Maintainer: felipe Status: ready --><!-- CREDITS: lucasr -->
|
|
<refentry xml:id="function.range" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>range</refname>
|
|
<refpurpose>Cria um array contendo uma faixa de elementos</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<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>
|
|
Cria um array contendo uma faixa de elementos
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>low</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
O valor mínimo.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>high</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
O valor máximo.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>step</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Se o parâmetro <parameter>step</parameter> for especificado, será usado
|
|
como o incremento entre os elementos da sequência. <parameter>step</parameter>
|
|
deve ser um inteiro positivo. Se não for especificado,
|
|
<parameter>step</parameter> terá valor igual a 1.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Retorna um array de elementos de <parameter>low</parameter> a
|
|
<parameter>high</parameter>, incluindo eles. Se low > high, a seqüência
|
|
será do maior para menor.
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<para>
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>5.0.0</entry>
|
|
<entry>
|
|
O parâmetro opcional <parameter>step</parameter> foi adicionado.
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>4.1.0 a 4.3.2</entry>
|
|
<entry>
|
|
Nas versões de PHP 4.1.0 até 4.3.2, <function>range</function> vê
|
|
strings numéricas como strings e não como inteiros. Em lugar disso, eles serão
|
|
usados por seqüência de caracteres. Por exemplo, <literal>"4242"</literal>
|
|
é tratado como <literal>"4"</literal>.
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>4.1.0</entry>
|
|
<entry>
|
|
Até a versão 4.1.0, a função <function>range</function> só gerava
|
|
arrays de inteiros em ordem crescente. O suporte para
|
|
seqüências de caracteres e arrays descrescentes foi adicionado no PHP 4.1.0.
|
|
Valores de seqüência de caracter estão limitados para o comprimento de um.
|
|
Se um comprimento maior do que um é entrado, apenas o primeiro caractere é usado.
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Exemplos da <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 $numero) {
|
|
echo $numero;
|
|
}
|
|
// O parâmetro step foi introduzido no 5.0.0
|
|
// array(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100)
|
|
|
|
foreach(range(0, 100, 10) as $numero) {
|
|
echo $numero;
|
|
}
|
|
// Utilização da sequência de caracteres introduzidos no 4.1.0
|
|
// array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i');
|
|
foreach(range('a', 'i') as $letra) {
|
|
|
|
echo $letra;
|
|
}
|
|
// array('c', 'b', 'a');
|
|
foreach(range('c', 'a') as $letra) {
|
|
|
|
echo $letra;
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<note>
|
|
<para>
|
|
|
|
</para>
|
|
</note>
|
|
<caution>
|
|
<para>
|
|
|
|
</para>
|
|
</caution>
|
|
<para>
|
|
Veja também <function>shuffle</function>,
|
|
<function>array_fill</function>, e
|
|
<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:"~/.phpdoc/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
|
|
-->
|