mirror of
https://github.com/php/doc-es.git
synced 2026-03-26 00:12:06 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@166216 c90b9560-bf6c-de11-be94-00142212c4b1
121 lines
3.7 KiB
XML
121 lines
3.7 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.6 $ -->
|
|
<!-- EN-Revision: 1.15 Maintainer: lboshell Status: ready -->
|
|
<!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
|
|
<refentry id="function.range">
|
|
<refnamediv>
|
|
<refname>range</refname>
|
|
<refpurpose>
|
|
Crea una matriz que contiene un rango de elementos
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Descripción</title>
|
|
<methodsynopsis>
|
|
<type>array</type><methodname>range</methodname>
|
|
<methodparam><type>number</type><parameter>bajo</parameter></methodparam>
|
|
<methodparam><type>number</type><parameter>alto</parameter></methodparam>
|
|
<methodparam choice="opt"><type>number</type><parameter>paso</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>rango</function> devuelve una matriz de elementos
|
|
desde <parameter>bajo</parameter>
|
|
hasta <parameter>alto</parameter>, ambos inclusive. Si bajo >
|
|
alto, la secuencia será del mayor al menor.
|
|
</para>
|
|
|
|
<note>
|
|
<title>Nuevo parámetro</title>
|
|
<simpara>
|
|
El parámetro opcional <parameter>paso</parameter> fue
|
|
añadido en 5.0.0.
|
|
</simpara>
|
|
</note>
|
|
<para>
|
|
Si un valor <parameter>paso</parameter> es dado, éste
|
|
será usado como el incremento entre elementos en la
|
|
secuencia. <parameter>paso</parameter> debería ser
|
|
definido como un número positivo. Si no se
|
|
especifica, <parameter>paso</parameter> tendrá un valor
|
|
predeterminado de 1.
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Ejemplos de <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;
|
|
}
|
|
|
|
// El parametro paso fue introducido en 5.0.0
|
|
// array(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100)
|
|
foreach (range(0, 100, 10) as $numero) {
|
|
echo $numero;
|
|
}
|
|
|
|
// Uso de secuencias de caracteres introducidas en 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>
|
|
Antes de PHP 4.1.0, <function>range</function> sólo
|
|
generaba matrices de enteros incrementales. El soporte para
|
|
secuencias de caracteres y matrices en decremento fue
|
|
añadido en 4.1.0. Los valores de secuencia de caracteres
|
|
esán limitados a una longitud de uno. Si una longitud
|
|
superior a uno es ingresada, solo se usa el primer caracter.
|
|
</para>
|
|
</note>
|
|
<caution>
|
|
<para>
|
|
En versiones de PHP desde 4.1.0 hasta
|
|
4.3.2, <function>range</function> considera las cadenas
|
|
numéricas como cadenas y no enteros. En su lugar, ellas
|
|
serán usadas para secuencias de caracteres. Por
|
|
ejemplo, <literal>"4242"</literal> es tratado
|
|
como <literal>"4"</literal>.
|
|
</para>
|
|
</caution>
|
|
<para>
|
|
Vea también <function>shuffle</function>,
|
|
<function>array_fill</function>, y
|
|
<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
|
|
-->
|