mirror of
https://github.com/php/doc-it.git
synced 2026-03-24 15:42:46 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/it/trunk@314534 c90b9560-bf6c-de11-be94-00142212c4b1
114 lines
3.7 KiB
XML
114 lines
3.7 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!-- splitted from ./it/functions/array.xml, last change in rev 1.1 -->
|
|
<!-- last change to 'range' in en/ tree in rev 1.2 -->
|
|
<!-- EN-Revision: n/a Maintainer: cucinato Status: ready -->
|
|
<!-- OLD-Revision: 1.173/EN.1.2 -->
|
|
<refentry xml:id="function.range" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>range</refname>
|
|
<refpurpose>
|
|
Crea un array contenente una serie di elementi
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Descrizione</title>
|
|
<methodsynopsis>
|
|
<type>array</type><methodname>range</methodname>
|
|
<methodparam><type>int</type><parameter>min</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>max</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>step</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>range</function> restituisce una serie di elementi da
|
|
<parameter>min</parameter> a <parameter>max</parameter>,
|
|
inclusiva. Se <parameter>min</parameter> > <parameter>max</parameter>, la sequenza sarà decrescente.
|
|
</para>
|
|
<note>
|
|
<title>Nuovo parametro</title>
|
|
<simpara>
|
|
Il parametro opzionale <parameter>step</parameter> è stato aggiunto nel PHP 5.0.0.
|
|
</simpara>
|
|
</note>
|
|
<para>
|
|
Se il valore <parameter>step</parameter> è specificato, verrà utilizzato come
|
|
incremento tra gli elementi della sequenza. <parameter>step</parameter>
|
|
deve essere un numero positivo. Se non specificato,
|
|
il valore predefinito per <parameter>step</parameter> è 1.
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>esempi di <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;
|
|
}
|
|
|
|
// Il parametro step è stato introdotto nel PHP 5.0.0
|
|
// array(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100)
|
|
foreach (range(0, 100, 10) as $numero) {
|
|
echo $numero;
|
|
}
|
|
|
|
// L'utilizzo dei caratteri è stato aggiunto nel PHP 4.1.0
|
|
// array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i');
|
|
foreach (range('a', 'i') as $lettera) {
|
|
echo $lettera;
|
|
}
|
|
// array('c', 'b', 'a');
|
|
foreach (range('c', 'a') as $lettera) {
|
|
echo $lettera;
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<note>
|
|
<para>
|
|
Prima della versione 4.1.0 la funzione <function>range</function> generava solo
|
|
array crescenti di interi. Il supporto per le sequenze di caratteri e
|
|
array decrescenti è stata aggiunta nella 4.1.0. I valori delle sequenze di caratteri
|
|
sono limitati alla lunghezza di 1 carattere. Se viene inserito un valore
|
|
con una lunghezza maggiore, viene utilizzato solo il primo carattere.
|
|
</para>
|
|
</note>
|
|
<caution>
|
|
<para>
|
|
Nel PHP dalla versione 4.1.0 alla 4.3.2, <function>range</function> vede
|
|
le stringhe numeriche come stringhe e non come interi. Quindi, verranno
|
|
utilizzate come sequenze di caratteri. Per esempio, <literal>"4242"</literal>
|
|
viene trattato come <literal>"4"</literal>.
|
|
</para>
|
|
</caution>
|
|
<para>
|
|
Vedere <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
|
|
-->
|