cvs: phpdoc-it /reference/array/functions in-array.xml key.xml krsort.xml ksort.xml list.xml range.xml reset.xml

From: Date: Sat, 03 Jan 2004 15:10:51 +0000
Subject: cvs: phpdoc-it /reference/array/functions in-array.xml key.xml krsort.xml ksort.xml list.xml range.xml reset.xml
Groups: php.doc.it 
Request: Send a blank email to doc-it+get-484@lists.php.net to get a copy of this message
cucinato Sat Jan 3 10:10:51 2004 EDT Modified files: /phpdoc-it/reference/array/functions in-array.xml key.xml krsort.xml ksort.xml list.xml range.xml reset.xml Log: iSync to EN tree

Index: phpdoc-it/reference/array/functions/in-array.xml diff -u phpdoc-it/reference/array/functions/in-array.xml:1.4 phpdoc-it/reference/array/functions/in-array.xml:1.5 --- phpdoc-it/reference/array/functions/in-array.xml:1.4 Sat Aug 10 09:13:18 2002 +++ phpdoc-it/reference/array/functions/in-array.xml Sat Jan 3 10:10:51 2004 @@ -1,12 +1,12 @@ <?xml version="1.0" encoding="iso-8859-1"?> <!-- splitted from ./it/functions/array.xml, last change in rev 1.7 --> <!-- last change to 'in-array' in en/ tree in rev 1.56 --> -<!-- EN-Revision: 1.5 Maintainer: cucinato Status: ready --> +<!-- EN-Revision: 1.11 Maintainer: cucinato Status: ready --> <!-- OLD-Revision: 1.173/EN.1.56 --> <refentry id="function.in-array"> <refnamediv> <refname>in_array</refname> - <refpurpose>Restituisce &true; se un valore &egrave; presente in un array</refpurpose> + <refpurpose>Controlla se un valore è presente in un array</refpurpose> </refnamediv> <refsect1> <title>Descrizione</title> @@ -44,24 +44,26 @@ <title>esempio di <function>in_array</function></title> <programlisting role="php"> <![CDATA[ -$os = array ("Mac", "NT", "Irix", "Linux"); -if (in_array ("Irix", $os)) { - print "Trovato Irix"; +<? +$os = array("Mac", "NT", "Irix", "Linux"); +if (in_array("Irix", $os)) { + echo "Trovato Irix"; } -if (in_array ("mac", $os)) { - print "Trovato mac"; +if (in_array("mac", $os)) { + echo "Trovato mac"; } +?> ]]> </programlisting> <para> La seconda condizione fallisce perché <function>in_array</function> tiene conto di maiuscole e minuscole, quindi il programma mostrerà: - <screen role="php"> + </para> + <screen> <![CDATA[ Trovato Irix ]]> - </screen> - </para> + </screen> </example> </para> <para> @@ -72,21 +74,24 @@ <?php $a = array('1.10', 12.4, 1.13); -if (in_array('12.4', $a, TRUE)) +if (in_array('12.4', $a, true)) { echo "'12.4' trovato con controllo strict\n" -if (in_array(1.13, $a, TRUE)) +} + +if (in_array(1.13, $a, true)) { echo "1.13 trovato con controllo strict\n" +} ?> ]]> </programlisting> <para> Questo mostrerà: - <screen role="php"> + </para> + <screen> <![CDATA[ 1.13 trovato con controllo strict ]]> - </screen> - </para> + </screen> </example> </para> <para> @@ -97,24 +102,35 @@ <?php $a = array(array('p', 'h'), array('p', 'r'), 'o'); -if (in_array(array ('p', 'h'), $a)) +if (in_array(array('p', 'h'), $a)) { echo "'ph' trovato\n"; -if (in_array(array ('f', 'i'), $a)) +} + +if (in_array(array('f', 'i'), $a)) { echo "'fi' non trovato\n"; -if (in_array('o', $a)) +} + +if (in_array('o', $a)) { echo "'o' trovato\n"; +} ?> - -// Questo ritornerà: - -'ph' trovato -'o' trovato ]]> </programlisting> + <para> + Questo ritornerà: + </para> + <screen> +<![CDATA[ + 'ph' trovato + 'o' trovato +]]> + </screen> </example> </para> <para> - Vedere anche <function>array_search</function>. + Vedere anche <function>array_search</function>, + <function>array_key_exists</function> e + <function>isset</function>. </para> </refsect1> </refentry> Index: phpdoc-it/reference/array/functions/key.xml diff -u phpdoc-it/reference/array/functions/key.xml:1.3 phpdoc-it/reference/array/functions/key.xml:1.4 --- phpdoc-it/reference/array/functions/key.xml:1.3 Sun May 12 18:14:11 2002 +++ phpdoc-it/reference/array/functions/key.xml Sat Jan 3 10:10:51 2004 @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="iso-8859-1"?> <!-- splitted from ./it/functions/array.xml, last change in rev 1.24 --> <!-- last change to 'key' in en/ tree in rev 1.2 --> -<!-- EN-Revision: 1.4 Maintainer: cucinato Status: ready --> +<!-- EN-Revision: 1.7 Maintainer: cucinato Status: ready --> <!-- OLD-Revision: 1.173/EN.1.2 --> <refentry id="function.key"> <refnamediv> @@ -19,6 +19,32 @@ all'attuale posizione del puntatore interno all'array. </para> <para> + <example> + <title>esempio di <function>key</function></title> + <programlisting role="php"> +<![CDATA[ +<?php +$array = array( + 'frutto1' => 'mela', + 'frutto2' => 'arancia', + 'frutto3' => 'uva', + 'frutto4' => 'mela', + 'frutto5' => 'mela'); + +// questo ciclo mostra tutte le chiavi +// dell'array associativo che sono uguali a 'mela' +while ($nome_frutto = current($array)( { + if ($nome_frutto == 'mela') { + echo key($array).'<br />'; + } + next($array); +} +?> +]]> + </programlisting> + </example> + </para> + <para> Vedere anche <function>current</function> e <function>next</function>. </para> </refsect1> Index: phpdoc-it/reference/array/functions/krsort.xml diff -u phpdoc-it/reference/array/functions/krsort.xml:1.3 phpdoc-it/reference/array/functions/krsort.xml:1.4 --- phpdoc-it/reference/array/functions/krsort.xml:1.3 Sun May 12 18:14:11 2002 +++ phpdoc-it/reference/array/functions/krsort.xml Sat Jan 3 10:10:51 2004 @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="iso-8859-1"?> <!-- splitted from ./it/functions/array.xml, last change in rev 1.1 --> <!-- last change to 'krsort' in en/ tree in rev 1.2 --> -<!-- EN-Revision: 1.4 Maintainer: cucinato Status: ready --> +<!-- EN-Revision: 1.8 Maintainer: cucinato Status: ready --> <!-- OLD-Revision: 1.173/EN.1.2 --> <refentry id="function.krsort"> <refnamediv> @@ -11,42 +11,47 @@ <refsect1> <title>Descrizione</title> <methodsynopsis> - <type>int</type><methodname>krsort</methodname> + <type>bool</type><methodname>krsort</methodname> <methodparam><type>array</type><parameter>array</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter>sort_flags</parameter></methodparam> </methodsynopsis> <para> Ordina un array rispetto alle sue chiavi, in ordine inverso, mantenendo - le associazioni. Questa funzione &egrave; utile con gli array associativi. + le associazioni. Questa funzione è utile con gli array associativi. + </para> + <para> + &return.success; + </para> + <para> <example> <title>Esempio di <function>krsort</function></title> <programlisting role="php"> <![CDATA[ -$frutti = array ("d"=>"limone", "a"=>"arancio", "b"=>"banana", "c"=>"mela"); -krsort ($frutti); -reset ($frutti); -while (list ($chiave, $valore) = each ($frutti)) { +<?php +$frutti = array("d"=>"limone", "a"=>"arancio", "b"=>"banana", "c"=>"mela"); +krsort($frutti); +reset($frutti); +while (list($chiave, $valore) = each($frutti)) { echo "$chiave = $valore\n"; } +?> ]]> </programlisting> - </example> - </para> - <para> - Questo esempio mostrer&agrave;: - </para> - <para> - <screen> + <para> + Questo esempio mostrerà: + </para> + <screen> <![CDATA[ d = limone c = mela b = banana a = arancio ]]> - </screen> + </screen> + </example> </para> <para> - Si pu&ograve; modificare il comportamento dell'ordinamento usando il parametro + Si può modificare il comportamento dell'ordinamento usando il parametro opzionale <parameter>sort_flags</parameter>, per ulteriori dettagli vedere <function>sort</function>. </para> Index: phpdoc-it/reference/array/functions/ksort.xml diff -u phpdoc-it/reference/array/functions/ksort.xml:1.3 phpdoc-it/reference/array/functions/ksort.xml:1.4 --- phpdoc-it/reference/array/functions/ksort.xml:1.3 Sun May 12 18:14:11 2002 +++ phpdoc-it/reference/array/functions/ksort.xml Sat Jan 3 10:10:51 2004 @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="iso-8859-1"?> <!-- splitted from ./it/functions/array.xml, last change in rev 1.1 --> <!-- last change to 'ksort' in en/ tree in rev 1.2 --> -<!-- EN-Revision: 1.4 Maintainer: cucinato Status: ready --> +<!-- EN-Revision: 1.8 Maintainer: cucinato Status: ready --> <!-- OLD-Revision: 1.173/EN.1.2 --> <refentry id="function.ksort"> <refnamediv> @@ -11,32 +11,36 @@ <refsect1> <title>Descrizione</title> <methodsynopsis> - <type>int</type><methodname>ksort</methodname> + <type>bool</type><methodname>ksort</methodname> <methodparam><type>array</type><parameter>array</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter>sort_flags</parameter></methodparam> </methodsynopsis> <para> Ordina un array rispetto alle sue chiavi, mantenendo le associazioni. Questa - funzione &egrave; utile con gli array associativi. + funzione è utile con gli array associativi. + </para> + <para> + &return.success; + </para> + <para> <example> <title>esempio di <function>ksort</function></title> <programlisting role="php"> <![CDATA[ -$frutti = array ("d"=>"limone", "a"=>"arancia", "b"=>"banana", "c"=>"mela"); -ksort ($frutti); -reset ($frutti); -while (list ($chiave, $valore) = each ($frutti)) { +<?php +$frutti = array("d"=>"limone", "a"=>"arancia", "b"=>"banana", "c"=>"mela"); +ksort($frutti); +reset($frutti); +while (list($chiave, $valore) = each($frutti)) { echo "$chiave = $valore\n"; } +?> ]]> </programlisting> - </example> - </para> - <para> - Questo esempio mostrer&agrave;: - </para> - <para> - <screen> + <para> + Questo esempio mostrerà: + </para> + <screen> <![CDATA[ a = arancia b = banana @@ -44,21 +48,22 @@ d = limone ]]> </screen> + </example> </para> <para> - Si pu&ograve; modificare il comportamento dell'ordinamento usando il parametro - opzionale <parameter>sort_flags</parameter>, per ulteriori dettagli + Si può modificare il comportamento dell'ordinamento usando il parametro + opzionale <parameter>sort_flags</parameter>, per ulteriori dettagli vedere <function>sort</function>. </para> <simpara> - Vedere anche <function>asort</function>, <function>arsort</function>, + Vedere anche <function>asort</function>, <function>arsort</function>, <function>krsort</function>, <function>uksort</function>, <function>sort</function>, <function>natsort</function> e <function>rsort</function>. </simpara> <note> <para> - Il secondo parametro &egrave; stato aggiunto in PHP 4. + Il secondo parametro è stato aggiunto in PHP 4. </para> </note> </refsect1> Index: phpdoc-it/reference/array/functions/list.xml diff -u phpdoc-it/reference/array/functions/list.xml:1.7 phpdoc-it/reference/array/functions/list.xml:1.8 --- phpdoc-it/reference/array/functions/list.xml:1.7 Mon Dec 8 16:52:39 2003 +++ phpdoc-it/reference/array/functions/list.xml Sat Jan 3 10:10:51 2004 @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="iso-8859-1"?> <!-- splitted from ./it/functions/array.xml, last change in rev 1.6 --> <!-- last change to 'list' in en/ tree in rev 1.2 --> -<!-- EN-Revision: 1.10 Maintainer: cucinato Status: ready --> +<!-- EN-Revision: 1.11 Maintainer: cucinato Status: ready --> <!-- OLD-Revision: 1.173/EN.1.2 --> <refentry id="function.list"> <refnamediv> @@ -38,15 +38,15 @@ // assegna a tutte le variabili list($bevanda, $colore, $componente) = $info; -print "Il $bevanda è $colore e la $componente lo rende speciale.\n"; +echo "Il $bevanda è $colore e la $componente lo rende speciale.\n"; // assegna solo in parte list($bevanda, , $componente) = $info; -print "Il $bevanda ha la $componente.\n"; +echo "Il $bevanda ha la $componente.\n"; // oppure assegnamo solo l'ultima variabile list( , , $componente) = $info; -print "Ho voglia di $bevanda!\n"; +echo"Ho voglia di $bevanda!\n"; ?> ]]> @@ -66,7 +66,7 @@ <?php -$risultato = mysql_query("SELECT id, nome, stipendio FROM impiegati",$conn); +$risultato = mysql_query("SELECT id, nome, stipendio FROM impiegati", $conn); while (list($id, $nome, $stipendio) = mysql_fetch_row ($risultato)) { echo (" <tr>\n". " <td><a href=\"info.php?id=$id\">$nome</a></td>\n". Index: phpdoc-it/reference/array/functions/range.xml diff -u phpdoc-it/reference/array/functions/range.xml:1.9 phpdoc-it/reference/array/functions/range.xml:1.10 --- phpdoc-it/reference/array/functions/range.xml:1.9 Thu Dec 11 04:20:23 2003 +++ phpdoc-it/reference/array/functions/range.xml Sat Jan 3 10:10:51 2004 @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="iso-8859-1"?> <!-- 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: 1.11 Maintainer: cucinato Status: ready --> +<!-- EN-Revision: 1.13 Maintainer: cucinato Status: ready --> <!-- OLD-Revision: 1.173/EN.1.2 --> <refentry id="function.range"> <refnamediv> @@ -42,23 +42,23 @@ <![CDATA[ <?php // array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) -foreach(range(0, 12) as $numero) { +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) { +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) { +foreach (range('a', 'i') as $lettera) { echo $lettera; } // array('c', 'b', 'a'); -foreach(range('c', 'a') as $lettera) { +foreach (range('c', 'a') as $lettera) { echo $lettera; } ?> @@ -70,7 +70,7 @@ <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 decresenti è stata aggiunta nella 4.1.0. I valori delle sequenze di caratteri + 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> Index: phpdoc-it/reference/array/functions/reset.xml diff -u phpdoc-it/reference/array/functions/reset.xml:1.3 phpdoc-it/reference/array/functions/reset.xml:1.4 --- phpdoc-it/reference/array/functions/reset.xml:1.3 Sun May 12 18:14:11 2002 +++ phpdoc-it/reference/array/functions/reset.xml Sat Jan 3 10:10:51 2004 @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="iso-8859-1"?> <!-- splitted from ./it/functions/array.xml, last change in rev 1.1 --> <!-- last change to 'reset' in en/ tree in rev 1.2 --> -<!-- EN-Revision: 1.4 Maintainer: cucinato Status: ready --> +<!-- EN-Revision: 1.10 Maintainer: cucinato Status: ready --> <!-- OLD-Revision: 1.173/EN.1.2 --> <refentry id="function.reset"> <refnamediv> @@ -18,11 +18,34 @@ </methodsynopsis> <para> <function>reset</function> riporta il puntatore di <parameter>array</parameter> - sul primo elemento. + sul primo elemento e ne restituisce il + valore. </para> <para> - <function>reset</function> restituisce il volore del primo elemento - dell'array. + <example> + <title>esempio di <function>reset</function></title> + <programlisting role="php"> +<![CDATA[ +<?php + +$array = array('passo uno', 'passo due', 'passo tre', 'passo quattro'); + +// di default, il puntatore è sul primo elemento +echo current($array) . "<br />\n"; // "passo uno" + +// salta due passi +next($array); +next($array); +echo current($array) . "<br />\n"; // "passo tre" + +// reset del puntatore, ricomincia dal passo uno +reset($array); +echo current($array) . "<br />\n"; // "passo uno" + +?> +]]> + </programlisting> + </example> </para> <para> Vedere anche <function>current</function>,
« previous php.doc.it (#484) next »