cvs: phpdoc-it /reference/array/functions array-keys.xml array-map.xml array-merge-recursive.xml array-merge.xml array-multisort.xml array-pop.xml
array-push.xml array-rand.xml array-reduce.xml array-shift.xml array-slice.xml array-splice.xml array-sum.xml array-unique.xml array-unshift.xml
array-values.xml array-walk.xml list.xml

From: Date: Mon, 08 Dec 2003 21:52:40 +0000
Subject: cvs: phpdoc-it /reference/array/functions array-keys.xml array-map.xml array-merge-recursive.xml array-merge.xml array-multisort.xml array-pop.xml
array-push.xml array-rand.xml array-reduce.xml array-shift.xml array-slice.xml array-splice.xml array-sum.xml array-unique.xml array-unshift.xml
array-values.xml array-walk.xml list.xml
Groups: php.doc.it 
Request: Send a blank email to doc-it+get-478@lists.php.net to get a copy of this message
cucinato Mon Dec 8 16:52:40 2003 EDT Modified files: /phpdoc-it/reference/array/functions array-keys.xml array-map.xml array-merge-recursive.xml array-merge.xml array-multisort.xml array-pop.xml array-push.xml array-rand.xml array-reduce.xml array-shift.xml array-slice.xml array-splice.xml array-sum.xml array-unique.xml array-unshift.xml array-values.xml array-walk.xml list.xml Log: Sync to EN tree

Index: phpdoc-it/reference/array/functions/array-keys.xml diff -u phpdoc-it/reference/array/functions/array-keys.xml:1.4 phpdoc-it/reference/array/functions/array-keys.xml:1.5 --- phpdoc-it/reference/array/functions/array-keys.xml:1.4 Sat Aug 9 07:22:00 2003 +++ phpdoc-it/reference/array/functions/array-keys.xml Mon Dec 8 16:52:39 2003 @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="iso-8859-1"?> <!-- splitted from ./it/functions/array.xml, last change in rev 1.11 --> <!-- last change to 'array-keys' in en/ tree in rev 1.2 --> -<!-- EN-Revision: 1.7 Maintainer: cucinato Status: ready --> +<!-- EN-Revision: 1.8 Maintainer: cucinato Status: ready --> <!-- OLD-Revision: 1.173/EN.1.2 --> <refentry id="function.array-keys"> <refnamediv> @@ -32,15 +32,15 @@ <programlisting role="php"> <![CDATA[ ?php -$array = array (0 => 100, "colore" => "rosso"); -print_r(array_keys ($array)) +$array = array(0 => 100, "colore" => "rosso"); +print_r(array_keys($array)) -$array = array ("blu", "rosso", "verde", "blu", "blu"); -print_r(array_keys ($array, "blu")); +$array = array("blu", "rosso", "verde", "blu", "blu"); +print_r(array_keys($array, "blu")); -$array = array ("colore" => array("blu", "rosso", "verde"), - "misura" =&gt; array("piccola", "media", "grande")); -print_r(array_keys ($array)); +$array = array("colore" => array("blu", "rosso", "verde"), + "misura" =&gt; array("piccola", "media", "grande")); +print_r(array_keys($array)); ?> ]]> </programlisting> Index: phpdoc-it/reference/array/functions/array-map.xml diff -u phpdoc-it/reference/array/functions/array-map.xml:1.6 phpdoc-it/reference/array/functions/array-map.xml:1.7 --- phpdoc-it/reference/array/functions/array-map.xml:1.6 Sat Aug 9 07:22:00 2003 +++ phpdoc-it/reference/array/functions/array-map.xml Mon Dec 8 16:52:39 2003 @@ -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 'array-map' in en/ tree in rev 1.62 --> -<!-- EN-Revision: 1.9 Maintainer: cucinato Status: ready --> +<!-- EN-Revision: 1.10 Maintainer: cucinato Status: ready --> <!-- OLD-Revision: 1.173/EN.1.62 --> <refentry id="function.array-map"> <refnamediv> @@ -34,7 +34,7 @@ <![CDATA[ <?php function cubo($n) { - return $n*$n*$n; + return($n * $n * $n); } $a = array(1, 2, 3, 4, 5); @@ -67,11 +67,11 @@ <![CDATA[ <?php function mostra_Spagnolo($n, $m) { - return "Il numero $n si dice $m in Spagnolo"; + return("Il numero $n si dice $m in Spagnolo"); } function mappa_Spagnolo($n, $m) { - return array ($n => $m); + return(array($n => $m)); } $a = array(1, 2, 3, 4, 5); Index: phpdoc-it/reference/array/functions/array-merge-recursive.xml diff -u phpdoc-it/reference/array/functions/array-merge-recursive.xml:1.4 phpdoc-it/reference/array/functions/array-merge-recursive.xml:1.5 --- phpdoc-it/reference/array/functions/array-merge-recursive.xml:1.4 Sat Aug 9 07:22:00 2003 +++ phpdoc-it/reference/array/functions/array-merge-recursive.xml Mon Dec 8 16:52:39 2003 @@ -1,12 +1,12 @@ <?xml version="1.0" encoding="iso-8859-1"?> <!-- splitted from ./it/functions/array.xml, last change in rev 1.6 --> <!-- last change to 'array-merge-recursive' in en/ tree in rev 1.12 --> -<!-- EN-Revision: 1.6 Maintainer: cucinato Status: ready --> +<!-- EN-Revision: 1.7 Maintainer: cucinato Status: ready --> <!-- OLD-Revision: 1.173/EN.1.12 --> <refentry id="function.array-merge-recursive"> <refnamediv> <refname>array_merge_recursive</refname> - <refpurpose>Fonde due o pi&ugrave; array in modo ricorsivo</refpurpose> + <refpurpose>Fonde due o più array in modo ricorsivo</refpurpose> </refnamediv> <refsect1> <title>Descrizione</title> @@ -35,9 +35,9 @@ <programlisting role="php"> <![CDATA[ <?php -$ar1 = array ("colore" => array ("preferito" => "rosso"), 5); -$ar2 = array (10, "colore" => array ("preferito" => "verde", "blu")); -$risultato = array_merge_recursive ($ar1, $ar2); +$ar1 = array("colore" => array ("preferito" => "rosso"), 5); +$ar2 = array(10, "colore" => array ("preferito" => "verde", "blu")); +$risultato = array_merge_recursive($ar1, $ar2); ?> ]]> </programlisting> Index: phpdoc-it/reference/array/functions/array-merge.xml diff -u phpdoc-it/reference/array/functions/array-merge.xml:1.8 phpdoc-it/reference/array/functions/array-merge.xml:1.9 --- phpdoc-it/reference/array/functions/array-merge.xml:1.8 Sun Aug 10 11:57:27 2003 +++ phpdoc-it/reference/array/functions/array-merge.xml Mon Dec 8 16:52:39 2003 @@ -1,12 +1,12 @@ <?xml version="1.0" encoding="iso-8859-1"?> <!-- splitted from ./it/functions/array.xml, last change in rev 1.6 --> <!-- last change to 'array-merge' 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.array-merge"> <refnamediv> <refname>array_merge</refname> - <refpurpose>Fonde due o pi&ugrave; array</refpurpose> + <refpurpose>Fonde due o più array</refpurpose> </refnamediv> <refsect1> <title>Descrizione</title> @@ -18,7 +18,7 @@ </methodsynopsis> <para> <function>array_merge</function> fonde gli elementi di due o - pi&ugrave; array in modo che i valori di un array siano accodati + più array in modo che i valori di un array siano accodati a quelli dell'array precedente. Restituisce l'array risultante. </para> <para> @@ -34,9 +34,9 @@ <programlisting role="php"> <![CDATA[ <?php -$array1 = array ("colore" => "rosso", 2, 4); -$array2 = array ("a", "b", "colore" => "verde", "forma" => "trapezio", 4); -$risultato = array_merge ($array1, $array2); +$array1 = array("colore" => "rosso", 2, 4); +$array2 = array("a", "b", "colore" => "verde", "forma" => "trapezio", 4); +$risultato = array_merge($array1, $array2); print_r($risultato); ?> ]]> Index: phpdoc-it/reference/array/functions/array-multisort.xml diff -u phpdoc-it/reference/array/functions/array-multisort.xml:1.5 phpdoc-it/reference/array/functions/array-multisort.xml:1.6 --- phpdoc-it/reference/array/functions/array-multisort.xml:1.5 Sun Aug 10 11:57:27 2003 +++ phpdoc-it/reference/array/functions/array-multisort.xml Mon Dec 8 16:52:39 2003 @@ -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 'array-multisort' in en/ tree in rev 1.11 --> -<!-- EN-Revision: 1.6 Maintainer: cucinato Status: ready --> +<!-- EN-Revision: 1.7 Maintainer: cucinato Status: ready --> <!-- OLD-Revision: 1.173/EN.1.11 --> <refentry id="function.array-multisort"> <refnamediv> @@ -75,9 +75,9 @@ <programlisting role="php"> <![CDATA[ <?php -$ar1 = array ("10", 100, 100, "a"); -$ar2 = array (1, 3, "2", 1); -array_multisort ($ar1, $ar2); +$ar1 = array("10", 100, 100, "a"); +$ar2 = array(1, 3, "2", 1); +array_multisort($ar1, $ar2); ?> ]]> </programlisting> @@ -95,9 +95,9 @@ <programlisting role="php"> <![CDATA[ <?php -$ar = array (array ("10", 100, 100, "a"), array (1, 3, "2", 1)); -array_multisort ($ar[0], SORT_ASC, SORT_STRING, - $ar[1], SORT_NUMERIC, SORT_DESC); +$ar = array(array ("10", 100, 100, "a"), array (1, 3, "2", 1)); +array_multisort($ar[0], SORT_ASC, SORT_STRING, + $ar[1], SORT_NUMERIC, SORT_DESC); ?> ]]> </programlisting> Index: phpdoc-it/reference/array/functions/array-pop.xml diff -u phpdoc-it/reference/array/functions/array-pop.xml:1.4 phpdoc-it/reference/array/functions/array-pop.xml:1.5 --- phpdoc-it/reference/array/functions/array-pop.xml:1.4 Sun Feb 9 13:57:09 2003 +++ phpdoc-it/reference/array/functions/array-pop.xml Mon Dec 8 16:52:39 2003 @@ -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 'array-pop' in en/ tree in rev 1.2 --> -<!-- EN-Revision: 1.5 Maintainer: cucinato Status: ready --> +<!-- EN-Revision: 1.8 Maintainer: cucinato Status: ready --> <!-- OLD-Revision: 1.173/EN.1.2 --> <refentry id="function.array-pop"> <refnamediv> @@ -30,15 +30,16 @@ <programlisting role="php"> <![CDATA[ <?php -$pila = array ("arancia", "banana", "mela", "lampone"); -$frutto = array_pop ($pila); +$pila = array("arancia", "banana", "mela", "lampone"); +$frutto = array_pop($pila); print_r($pila); ?> ]]> </programlisting> <para> Dopo questa istruzione, <varname>$pila</varname> avrà solo 3 elementi: - <screen role="php"> + </para> + <screen role="php"> <![CDATA[ Array ( @@ -47,8 +48,9 @@ [2] => mela ) ]]> - </screen> - e <literal>lampone</literal> verràa assegnato alla variabile + </screen> + <para> + e <literal>lampone</literal> verrà assegnato alla variabile <varname>$frutto</varname>. </para> </example> Index: phpdoc-it/reference/array/functions/array-push.xml diff -u phpdoc-it/reference/array/functions/array-push.xml:1.4 phpdoc-it/reference/array/functions/array-push.xml:1.5 --- phpdoc-it/reference/array/functions/array-push.xml:1.4 Sun Feb 9 13:57:09 2003 +++ phpdoc-it/reference/array/functions/array-push.xml Mon Dec 8 16:52:39 2003 @@ -1,13 +1,13 @@ <?xml version="1.0" encoding="iso-8859-1"?> <!-- splitted from ./it/functions/array.xml, last change in rev 1.1 --> <!-- last change to 'array-push' in en/ tree in rev 1.2 --> -<!-- EN-Revision: 1.5 Maintainer: cucinato Status: ready --> +<!-- EN-Revision: 1.8 Maintainer: cucinato Status: ready --> <!-- OLD-Revision: 1.173/EN.1.2 --> <refentry id="function.array-push"> <refnamediv> <refname>array_push</refname> <refpurpose> - Accoda uno o pi&ugrave; elementi ad un array + Accoda uno o più elementi ad un array </refpurpose> </refnamediv> <refsect1> @@ -26,7 +26,9 @@ variabili accodate. Ha lo stesso effetto di: <programlisting role="php"> <![CDATA[ +<?php $array[] = $var; +?> ]]> </programlisting> ripetuto per ogni <parameter>var</parameter>. @@ -39,15 +41,18 @@ <title>esempio di <function>array_push</function></title> <programlisting role="php"> <![CDATA[ -$pila = array ("arancia", "banana"); -array_push ($pila, "mela", "lampone"); +<?php +$pila = array("arancia", "banana"); +array_push($pila, "mela", "lampone"); print_r($pila); +?> ]]> </programlisting> <para> In questo esempio <varname>$pila</varname> avrà i seguenti elementi: - <screen role="php"> + </para> + <screen role="php"> <![CDATA[ Array ( @@ -57,8 +62,7 @@ [3] => lampone ) ]]> - </screen> - </para> + </screen> </example> </para> <para> Index: phpdoc-it/reference/array/functions/array-rand.xml diff -u phpdoc-it/reference/array/functions/array-rand.xml:1.3 phpdoc-it/reference/array/functions/array-rand.xml:1.4 --- phpdoc-it/reference/array/functions/array-rand.xml:1.3 Sun May 12 18:14:11 2002 +++ phpdoc-it/reference/array/functions/array-rand.xml Mon Dec 8 16:52:39 2003 @@ -1,13 +1,13 @@ <?xml version="1.0" encoding="iso-8859-1"?> <!-- splitted from ./it/functions/array.xml, last change in rev 1.6 --> <!-- last change to 'array-rand' in en/ tree in rev 1.13 --> -<!-- EN-Revision: 1.4 Maintainer: cucinato Status: ready --> +<!-- EN-Revision: 1.8 Maintainer: cucinato Status: ready --> <!-- OLD-Revision: 1.173/EN.1.13 --> <refentry id="function.array-rand"> <refnamediv> <refname>array_rand</refname> <refpurpose> - Estrae a caso uno o pi&ugrave; elementi da un array + Estrae a caso uno o più elementi da un array </refpurpose> </refnamediv> <refsect1> @@ -18,11 +18,11 @@ <methodparam choice="opt"><type>int</type><parameter>num_req</parameter></methodparam> </methodsynopsis> <para> - <function>array_rand</function> &egrave; piuttosto utile quando si vuole - estrarre a caso uno o pi&ugrave; elementi da un array. Prende un + <function>array_rand</function> è piuttosto utile quando si vuole + estrarre a caso uno o più elementi da un array. Prende un array (<parameter>input</parameter>) e un argomento ozpionale (<parameter>num_req</parameter>) che specifica quanti elementi - estrarre - se non &egrave; specificato, &egrave; 1 per default. + estrarre - se non è specificato, è 1 per default. </para> <para> Se si sta estraendo solo un elemento, <function>array_rand</function> @@ -30,24 +30,28 @@ di chiavi. Questo viene fatto in modo da permettere di estrarre dall'array sia le chiavi che i valori. </para> - <para> - Non dimenticare di chiamare <function>srand</function> per perturbare il - generatore di numri casuali. - </para> + + &note.randomseed; + <para> <example> <title>esempio di <function>array_rand</function></title> <programlisting role="php"> <![CDATA[ -srand ((float) microtime() * 10000000); -$input = array ("Neo", "Morpheus", "Trinity", "Cypher", "Tank"); -$chiavi = array_rand ($input, 2); -print $input[$chiavi[0]]."\n"; -print $input[$chiavi[1]]."\n"; +<? +srand((float) microtime() * 10000000); +$input = array("Neo", "Morpheus", "Trinity", "Cypher", "Tank"); +$chiavi = array_rand($input, 2); +print $input[$chiavi[0]] . "\n"; +print $input[$chiavi[1]] . "\n"; +?> ]]> </programlisting> </example> </para> + <para> + Vedere anche <function>shuffle</function>. + </para> </refsect1> </refentry> Index: phpdoc-it/reference/array/functions/array-reduce.xml diff -u phpdoc-it/reference/array/functions/array-reduce.xml:1.4 phpdoc-it/reference/array/functions/array-reduce.xml:1.5 --- phpdoc-it/reference/array/functions/array-reduce.xml:1.4 Mon Dec 9 19:33:18 2002 +++ phpdoc-it/reference/array/functions/array-reduce.xml Mon Dec 8 16:52:39 2003 @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="iso-8859-1"?> <!-- splitted from ./it/functions/array.xml, last change in rev 1.11 --> <!-- last change to 'array-reduce' in en/ tree in rev 1.2 --> -<!-- EN-Revision: 1.5 Maintainer: cucinato Status: ready --> +<!-- EN-Revision: 1.7 Maintainer: cucinato Status: ready --> <!-- OLD-Revision: 1.173/EN.1.2 --> <refentry id="function.array-reduce"> <refnamediv> @@ -32,6 +32,7 @@ <title>esempio di <function>array_reduce</function></title> <programlisting role="php"> <![CDATA[ +<?php function rsum($v, $w) { $v += $w; return $v; @@ -47,6 +48,7 @@ $b = array_reduce($a, "rsum"); $c = array_reduce($a, "rmul", 10); $d = array_reduce($x, "rsum", 1); +?> ]]> </programlisting> </example> @@ -59,7 +61,9 @@ </para> <para> Vedere anche <function>array_filter</function> e - <function>array_map</function>. + <function>array_map</function>, + <function>array_unique</function> e + <function>array_count_values</function>. </para> </refsect1> </refentry> Index: phpdoc-it/reference/array/functions/array-shift.xml diff -u phpdoc-it/reference/array/functions/array-shift.xml:1.5 phpdoc-it/reference/array/functions/array-shift.xml:1.6 --- phpdoc-it/reference/array/functions/array-shift.xml:1.5 Sun Feb 9 13:57:09 2003 +++ phpdoc-it/reference/array/functions/array-shift.xml Mon Dec 8 16:52:39 2003 @@ -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 'array-shift' in en/ tree in rev 1.2 --> -<!-- EN-Revision: 1.7 Maintainer: cucinato Status: ready --> +<!-- EN-Revision: 1.9 Maintainer: cucinato Status: ready --> <!-- OLD-Revision: 1.173/EN.1.2 --> <refentry id="function.array-shift"> <refnamediv> @@ -27,21 +27,21 @@ &array.resetspointer; - <para> - <example> - <title>esempio di <function>array_shift</function></title> - <programlisting role="php"> + <example> + <title>esempio di <function>array_shift</function></title> + <programlisting role="php"> <![CDATA[ <?php -$pila = array ("arancia", "banana", "mela", lampone"); -$frutto = array_shift ($pila); +$pila = array("arancia", "banana", "mela", lampone"); +$frutto = array_shift($pila); print_r($pila); ?> ]]> - </programlisting> - <para> - In questo modo <varname>$pila</varname> rimarrà con 3 elementi: - <screen role="php"> + </programlisting> + <para> + In questo modo <varname>$pila</varname> rimarrà con 3 elementi: + </para> + <screen role="php"> <![CDATA[ Array ( @@ -50,12 +50,12 @@ [2] => lampone ) ]]> - </screen> - e <literal>arancia</literal> sarà assegnata a - <varname>$frutto</varname>. - </para> - </example> - </para> + </screen> + <para> + e <literal>arancia</literal> sarà assegnata a + <varname>$frutto</varname>. + </para> + </example> <para> Vedere anche <function>array_unshift</function>, <function>array_push</function> e Index: phpdoc-it/reference/array/functions/array-slice.xml diff -u phpdoc-it/reference/array/functions/array-slice.xml:1.4 phpdoc-it/reference/array/functions/array-slice.xml:1.5 --- phpdoc-it/reference/array/functions/array-slice.xml:1.4 Mon Jun 2 05:25:37 2003 +++ phpdoc-it/reference/array/functions/array-slice.xml Mon Dec 8 16:52:39 2003 @@ -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 'array-slice' in en/ tree in rev 1.2 --> -<!-- EN-Revision: 1.5 Maintainer: cucinato Status: ready --> +<!-- EN-Revision: 1.7 Maintainer: cucinato Status: ready --> <!-- OLD-Revision: 1.173/EN.1.2 --> <refentry id="function.array-slice"> <refnamediv> @@ -52,17 +52,18 @@ <?php $input = array ("a", "b", "c", "d", "e"); -$output = array_slice ($input, 2); // restituisce "c", "d" e "e" -$output = array_slice ($input, 2, -1); // restituisce "c", "d" -$output = array_slice ($input, -2, 1); // restituisce "d" -$output = array_slice ($input, 0, 3); // restituisce "a", "b" e "c" +$output = array_slice($input, 2); // restituisce "c", "d" e "e" +$output = array_slice($input, 2, -1); // restituisce "c", "d" +$output = array_slice($input, -2, 1); // restituisce "d" +$output = array_slice($input, 0, 3); // restituisce "a", "b" e "c" ?> ]]> </programlisting> </example> </para> <para> - Vedere anche <function>array_splice</function>. + Vedere anche <function>array_splice</function> e + <function>unset</function>. </para> </refsect1> </refentry> Index: phpdoc-it/reference/array/functions/array-splice.xml diff -u phpdoc-it/reference/array/functions/array-splice.xml:1.6 phpdoc-it/reference/array/functions/array-splice.xml:1.7 --- phpdoc-it/reference/array/functions/array-splice.xml:1.6 Mon Jun 2 05:25:37 2003 +++ phpdoc-it/reference/array/functions/array-splice.xml Mon Dec 8 16:52:39 2003 @@ -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 'array-splice' in en/ tree in rev 1.14 --> -<!-- EN-Revision: 1.7 Maintainer: cucinato Status: ready --> +<!-- EN-Revision: 1.9 Maintainer: cucinato Status: ready --> <!-- OLD-Revision: 1.173/EN.1.14 --> <refentry id="function.array-splice"> <refnamediv> @@ -120,29 +120,36 @@ <programlisting role="php"> <![CDATA[ <?php -$input = array ("rosso", "verde", "blu", "giallo"); -array_splice ($input, 2); -// $input è ora array ("rosso", "verde") +$input = array("rosso", "verde", "blu", "giallo"); +array_splice($input, 2); +// $input è ora array("rosso", "verde") -$input = array ("rosso", "verde", "blu", "giallo"); -array_splice ($input, 1, -1); -// $input è ora array ("rosso", "giallo") +$input = array("rosso", "verde", "blu", "giallo"); +array_splice($input, 1, -1); +// $input è ora array("rosso", "giallo") -$input = array ("rosso", "verde", "blu", "giallo"); -array_splice ($input, 1, count($input), "arancio"); -// $input è ora array ("rosso", "arancio") +$input = array("rosso", "verde", "blu", "giallo"); +array_splice($input, 1, count($input), "arancio"); +// $input è ora array("rosso", "arancio") -$input = array ("rosso", "verde", "blu", "giallo"); -array_splice ($input, -1, 1, array("nero", "marrone")); -// $input è ora array ("rosso", "verde", +$input = array("rosso", "verde", "blu", "giallo"); +array_splice($input, -1, 1, array("nero", "marrone")); +// $input è ora array("rosso", "verde", // "blu", "nero", "marrone") + +$input = array("rosso", "verde", "blu", "giallo"); +array_splice($input, 3, 0, "viola"); +// $input è ora array("rosso", "verde", +// "blu", "viola", "giallo"); ?> ]]> </programlisting> </example> </para> <para> - Vedere anche <function>array_slice</function>. + Vedere anche <function>array_slice</function>i, + <function>unset</function> e + <function>array_merge</function>. </para> </refsect1> </refentry> Index: phpdoc-it/reference/array/functions/array-sum.xml diff -u phpdoc-it/reference/array/functions/array-sum.xml:1.4 phpdoc-it/reference/array/functions/array-sum.xml:1.5 --- phpdoc-it/reference/array/functions/array-sum.xml:1.4 Mon Jun 2 05:25:37 2003 +++ phpdoc-it/reference/array/functions/array-sum.xml Mon Dec 8 16:52:39 2003 @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="iso-8859-1"?> <!-- splitted from ./it/functions/array.xml, last change in rev 1.7 --> <!-- last change to 'array-sum' in en/ tree in rev 1.59 --> -<!-- EN-Revision: 1.6 Maintainer: cucinato Status: ready --> +<!-- EN-Revision: 1.7 Maintainer: cucinato Status: ready --> <!-- OLD-Revision: 1.173/EN.1.59 --> <refentry id="function.array-sum"> <refnamediv> @@ -36,13 +36,13 @@ </programlisting> <para> Il risultato di questo programma sarà: - <screen role="php"> + </para> + <screen> <![CDATA[ sum(a) = 20 sum(b) = 6.9 ]]> - </screen> - </para> + </screen> </example> </para> <note> Index: phpdoc-it/reference/array/functions/array-unique.xml diff -u phpdoc-it/reference/array/functions/array-unique.xml:1.4 phpdoc-it/reference/array/functions/array-unique.xml:1.5 --- phpdoc-it/reference/array/functions/array-unique.xml:1.4 Sun Feb 9 15:58:51 2003 +++ phpdoc-it/reference/array/functions/array-unique.xml Mon Dec 8 16:52:39 2003 @@ -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 'array-unique' in en/ tree in rev 1.2 --> -<!-- EN-Revision: 1.10 Maintainer: cucinato Status: ready --> +<!-- EN-Revision: 1.12 Maintainer: cucinato Status: ready --> <!-- OLD-Revision: 1.173/EN.1.2 --> <refentry id="function.array-unique"> <refnamediv> @@ -42,15 +42,16 @@ <programlisting role="php"> <![CDATA[ <?php -$input = array ("a" => "verde", "rosso", "b" => "verde", "blu", "rosso"); -$risultato = array_unique ($input); +$input = array("a" => "verde", "rosso", "b" => "verde", "blu", "rosso"); +$risultato = array_unique($input); print_r($result); ?> ]]> </programlisting> <para> Questo mostrerà: - <screen role="php"> + </para> + <screen role="php"> <![CDATA[ Array ( @@ -59,8 +60,7 @@ [2] => rosso ) ]]> - </screen> - </para> + </screen> </example> </para> <para> @@ -69,23 +69,23 @@ <programlisting role="php"> <![CDATA[ <?php -$input = array (4,"4","3",4,3,"3"); -$risultato = array_unique ($input); +$input = array(4,"4","3",4,3,"3"); +$risultato = array_unique($input); var_dump($risultato); ?> ]]> </programlisting> <para> Questo script mostrerà: - <screen role="php"> + </para> + <screen role="php"> <![CDATA[ array(2) { [0] => int(4) [2] => string(1) "3" } ]]> - </screen> - </para> + </screen> </example> </para> </refsect1> Index: phpdoc-it/reference/array/functions/array-unshift.xml diff -u phpdoc-it/reference/array/functions/array-unshift.xml:1.5 phpdoc-it/reference/array/functions/array-unshift.xml:1.6 --- phpdoc-it/reference/array/functions/array-unshift.xml:1.5 Mon Jun 2 05:25:37 2003 +++ phpdoc-it/reference/array/functions/array-unshift.xml Mon Dec 8 16:52:39 2003 @@ -1,13 +1,13 @@ <?xml version="1.0" encoding="iso-8859-1"?> <!-- splitted from ./it/functions/array.xml, last change in rev 1.1 --> <!-- last change to 'array-unshift' in en/ tree in rev 1.2 --> -<!-- EN-Revision: 1.6 Maintainer: cucinato Status: ready --> +<!-- EN-Revision: 1.8 Maintainer: cucinato Status: ready --> <!-- OLD-Revision: 1.173/EN.1.2 --> <refentry id="function.array-unshift"> <refnamediv> <refname>array_unshift</refname> <refpurpose> - Inserisce uno o pi&ugrave; elementi all'inizio dell'array + Inserisce uno o più elementi all'inizio dell'array </refpurpose> </refnamediv> <refsect1> @@ -23,7 +23,7 @@ <para> <function>array_unshift</function> aggiunge gli elementi specificati in testa ad <parameter>array</parameter>. Si noti che la lista - di elementi &egrave; aggiunta in blocco, in modo tale che gli + di elementi è aggiunta in blocco, in modo tale che gli elementi rimangano nello stesso ordine. Tutte le chiavi numeriche vengono modificate per iniziare da zero mentre le chiavi alfabetiche non sono modificate. </para> @@ -37,15 +37,16 @@ <programlisting role="php"> <![CDATA[ <?php -$lista = array ("arancia", "banana"); -array_unshift ($lista, "mela", "lampone"); +$lista = array("arancia", "banana"); +array_unshift($lista, "mela", "lampone"); ?> ]]> </programlisting> <para> In questo modo <varname>$lista</varname> conterrà i seguenti elementi: - <screen role="php"> + </para> + <screen role="php"> <![CDATA[ Array ( @@ -55,8 +56,7 @@ [3] => banana ) ]]> - </screen> - </para> + </screen> </example> </para> <para> Index: phpdoc-it/reference/array/functions/array-values.xml diff -u phpdoc-it/reference/array/functions/array-values.xml:1.5 phpdoc-it/reference/array/functions/array-values.xml:1.6 --- phpdoc-it/reference/array/functions/array-values.xml:1.5 Mon Jun 2 05:25:37 2003 +++ phpdoc-it/reference/array/functions/array-values.xml Mon Dec 8 16:52:39 2003 @@ -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 'array-values' in en/ tree in rev 1.2 --> -<!-- EN-Revision: 1.6 Maintainer: cucinato Status: ready --> +<!-- EN-Revision: 1.8 Maintainer: cucinato Status: ready --> <!-- OLD-Revision: 1.173/EN.1.2 --> <refentry id="function.array-values"> <refnamediv> @@ -25,14 +25,15 @@ <programlisting role="php"> <![CDATA[ <?php -$array = array ("taglia" => "XL", "colore" => "oro"); +$array = array("taglia" => "XL", "colore" => "oro"); print_r(array_values ($array)); ?> ]]> </programlisting> <para> Questo mostrerà: - <screen role="php"> + </para> + <screen role="php"> <![CDATA[ Array ( @@ -40,8 +41,7 @@ [1] => oro ) ]]> - </screen> - </para> + </screen> </example> </para> <para> Index: phpdoc-it/reference/array/functions/array-walk.xml diff -u phpdoc-it/reference/array/functions/array-walk.xml:1.7 phpdoc-it/reference/array/functions/array-walk.xml:1.8 --- phpdoc-it/reference/array/functions/array-walk.xml:1.7 Sun May 4 10:12:50 2003 +++ phpdoc-it/reference/array/functions/array-walk.xml Mon Dec 8 16:52:39 2003 @@ -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 'array-walk' in en/ tree in rev 1.2 --> -<!-- EN-Revision: 1.10 Maintainer: cucinato Status: ready --> +<!-- EN-Revision: 1.12 Maintainer: cucinato Status: ready --> <!-- OLD-Revision: 1.173/EN.1.2 --> <refentry id="function.array-walk"> <refnamediv> @@ -77,29 +77,30 @@ <programlisting role="php"> <![CDATA[ <?php -$frutta = array ("d"=>"limone", "a"=>"arancia", "b"=>"banana", "c"=>"mela"); +$frutta = array("d"=>"limone", "a"=>"arancia", "b"=>"banana", "c"=>"mela"); -function modifica (&$elemento1, $chiave, $prefisso) { +function modifica(&$elemento1, $chiave, $prefisso) { $elemento1 = "$prefisso: $elemento1"; } -function stampa ($elemento2, $chiave) { +function stampa($elemento2, $chiave) { echo "$chiave. $elemento2<br>\n"; } echo "Prima ...:\n"; -array_walk ($frutta, 'stampa'); +array_walk($frutta, 'stampa'); -array_walk ($frutta, 'modifica', 'frutto'); +array_walk($frutta, 'modifica', 'frutto'); echo "... e dopo:\n"; -array_walk ($frutta, 'stampa'); +array_walk($frutta, 'stampa'); ?> ]]> </programlisting> <para> Il risultato del programma sarà: - <screen role="php"> + </para> + <screen role="php"> <![CDATA[ Prima ...: d. limone @@ -113,7 +114,6 @@ c. frutto: mela ]]> </screen> - </para> </example> </para> <simpara> Index: phpdoc-it/reference/array/functions/list.xml diff -u phpdoc-it/reference/array/functions/list.xml:1.6 phpdoc-it/reference/array/functions/list.xml:1.7 --- phpdoc-it/reference/array/functions/list.xml:1.6 Mon Dec 9 19:33:18 2002 +++ phpdoc-it/reference/array/functions/list.xml Mon Dec 8 16:52:39 2003 @@ -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.7 Maintainer: cucinato Status: ready --> +<!-- EN-Revision: 1.10 Maintainer: cucinato Status: ready --> <!-- OLD-Revision: 1.173/EN.1.2 --> <refentry id="function.list"> <refnamediv> @@ -66,12 +66,12 @@ <?php -$risultato = mysql_query ("SELECT id, nome, stipendio FROM impiegati",$conn); -while (list ($id, $nome, $stipendio) = mysql_fetch_row ($risultato)) { - print (" <tr>\n". - " <td><a href=\"info.php?id=$id\">$nome</a></td>\n". - " <td>$stipendio</td>\n". - " </tr>\n"); +$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". + " <td>$stipendio</td>\n". + " </tr>\n"); } ?> @@ -82,19 +82,19 @@ </example> </para> <warning> - <para> + <para> <function>list</function> assegna i valori cominciando dal parametro più a destra. Se si stanno usando variabili semplici, non ci si deve preoccupare di questo fatto. Ma se si stanno usando array con indici di solito ci si aspetta che l'ordine degli indici negli array sia quello scritto negli argomenti della funzione <function>list</function>, da sinistra a destra; non è così. L'ordine è invertito. - </para> - </warning> - <para> - <example> - <title>Utilizzo di <function>list</function> con gli indici</title> - <programlisting role="php"> + </para> + </warning> + <para> + <example> + <title>Utilizzo di <function>list</function> con gli indici</title> + <programlisting role="php"> <![CDATA[ <?php @@ -107,10 +107,12 @@ ?> ]]> </programlisting> - </example> - Restituisce il segente risultato (si noti l'ordine degli elementi rispetto - all'ordine con cui sono stati scritti nella sintassi di <function>list</function>). - <screen> + <para> + Restituisce il segente risultato (si noti l'ordine degli elementi rispetto + all'ordine con cui sono stati scritti nella sintassi di <function>list</function>). + </para> + <screen> +<![CDATA[ array(3) { [2]=> string(8) "caffeina" @@ -119,7 +121,9 @@ [0]=> string(5) "caffè" } - </screen> +]]> + </screen> + </example> </para> <para> Vedere anche <function>each</function> e <function>array</function>
« previous php.doc.it (#478) next »