Date: 07/23/00
- Next message: Martin Samesch: "[PHP-DOC] cvs: phpdoc /en/functions mssql.xml"
- Previous message: Jani Taskinen: "[PHP-DOC] cvs: phpdoc /en/functions ldap.xml"
- Next in thread: Egon Schmid: "[PHP-DOC] cvs: phpdoc /en/functions array.xml"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
eschmid Sun Jul 23 10:03:59 2000 EDT
Modified files:
/phpdoc/en/functions array.xml
Log:
Some enhancements.
Index: phpdoc/en/functions/array.xml
diff -u phpdoc/en/functions/array.xml:1.14 phpdoc/en/functions/array.xml:1.15
--- phpdoc/en/functions/array.xml:1.14 Sat Jul 22 01:38:36 2000
+++ phpdoc/en/functions/array.xml Sun Jul 23 10:03:59 2000
@@ -1,5 +1,5 @@
<reference id="ref.array">
- <title>Array functions</title>
+ <title>Array Functions</title>
<titleabbrev>Arrays</titleabbrev>
<refentry id="function.array">
@@ -22,7 +22,7 @@
an index with the <literal>=></literal> operator.
<note>
<para>
- <function>array</function> is a language construct used to
+ <function>Array</function> is a language construct used to
represent literal arrays, and not a regular function.
</para>
</note>
@@ -33,12 +33,12 @@
arrays, and how to skip-and-continue numeric indices in normal
arrays.
<example>
- <title><function>array</function> example</title>
+ <title><function>Array</function> example</title>
<programlisting role="php">
$fruits = array (
- "fruits" => array("a"=>"orange", "b"=>"banana", "c"=>"apple"),
- "numbers" => array(1, 2, 3, 4, 5, 6),
- "holes" => array("first", 5 => "second", "third")
+ "fruits" => array ("a"=>"orange", "b"=>"banana", "c"=>"apple"),
+ "numbers" => array (1, 2, 3, 4, 5, 6),
+ "holes" => array ("first", 5 => "second", "third")
);
</programlisting>
</example>
@@ -63,23 +63,18 @@
</funcprototype>
</funcsynopsis>
<para>
- <function>array_count_values</function> returns an array using
+ <function>Array_count_values</function> returns an array using
the values of the <parameter>input</parameter> array as keys and
their frequency in <parameter>input</parameter> as values.
</para>
<para>
<example>
- <title><function>array_count_values</function> example</title>
+ <title><function>Array_count_values</function> example</title>
<programlisting role="php">
-$array = array(1, "hello", 1, "world", "hello");
-array_count_values($array); // returns array(1=>2, "hello"=>2, "world"=>1)
+$array = array (1, "hello", 1, "world", "hello");
+array_count_values ($array); // returns array (1=>2, "hello"=>2, "world"=>1)
</programlisting>
</example>
- <note>
- <para>
- This function was added in PHP 4.0.
- </para>
- </note>
</para>
</refsect1>
</refentry>
@@ -96,19 +91,19 @@
<funcdef>array <function>array_diff</function></funcdef>
<paramdef>array <parameter>array1</parameter></paramdef>
<paramdef>array <parameter>array2</parameter></paramdef>
- <paramdef>
+ <paramdef>array
<parameter><optional> ...</optional></parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>
- <function>array_diff</function> returns an array
+ <function>Array_diff</function> returns an array
containing all the values of <parameter>array1</parameter>
that are not present in any of the other arguments.
</para>
<para>
<example>
- <title><function>array_diff</function> example</title>
+ <title><function>Array_diff</function> example</title>
<programlisting role="php">
$array1 = array ("a" => "green", "red", "blue");
$array2 = array ("b" => "green", "yellow", "red");
@@ -121,11 +116,6 @@
</para>
<para>
See also <function>array_intersect</function>.
- <note>
- <para>
- This function was added in PHP 4.0.1.
- </para>
- </note>
</para>
</refsect1>
</refentry>
@@ -144,21 +134,16 @@
</funcprototype>
</funcsynopsis>
<para>
- <function>array_flip</function> returns an array in flip order.
+ <function>Array_flip</function> returns an array in flip order.
</para>
<para>
<example>
- <title><function>array_flip</function> example</title>
+ <title><function>Array_flip</function> example</title>
<programlisting role="php">
$trans = array_flip ($trans);
$original = strtr ($str, $trans);
</programlisting>
</example>
- <note>
- <para>
- This function was added in PHP 4.0.
- </para>
- </note>
</para>
</refsect1>
</refentry>
@@ -175,19 +160,19 @@
<funcdef>array <function>array_intersect</function></funcdef>
<paramdef>array <parameter>array1</parameter></paramdef>
<paramdef>array <parameter>array2</parameter></paramdef>
- <paramdef>
+ <paramdef>array
<parameter><optional> ...</optional></parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>
- <function>array_intersect</function> returns an array
+ <function>Array_intersect</function> returns an array
containing all the values of <parameter>array1</parameter>
that are present in all the arguments.
</para>
<para>
<example>
- <title><function>array_intersect</function> example</title>
+ <title><function>Array_intersect</function> example</title>
<programlisting role="php">
$array1 = array ("a" => "green", "red", "blue");
$array2 = array ("b" => "green", "yellow", "red");
@@ -200,11 +185,6 @@
</para>
<para>
See also <function>array_diff</function>.
- <note>
- <para>
- This function was added in PHP 4.0.1.
- </para>
- </note>
</para>
</refsect1>
</refentry>
@@ -228,7 +208,7 @@
</funcprototype>
</funcsynopsis>
<para>
- <function>array_keys</function> returns the keys, numeric and
+ <function>Array_keys</function> returns the keys, numeric and
string, from the <parameter>input</parameter> array.
</para>
<para>
@@ -238,23 +218,18 @@
</para>
<para>
<example>
- <title><function>array_keys</function> example</title>
+ <title><function>Array_keys</function> example</title>
<programlisting role="php">
-$array = array(0 => 100, "color" => "red");
+$array = array (0 => 100, "color" => "red");
array_keys ($array); // returns array (0, "color")
-$array = array(1, 100, 2, 100);
+$array = array (1, 100, 2, 100);
array_keys ($array, 100); // returns array (0, 2)
</programlisting>
</example>
</para>
<para>
See also <function>array_values</function>.
- <note>
- <para>
- This function was added in PHP 4.0.
- </para>
- </note>
</para>
</refsect1>
</refentry>
@@ -271,13 +246,13 @@
<funcdef>array <function>array_merge</function></funcdef>
<paramdef>array <parameter>array1</parameter></paramdef>
<paramdef>array <parameter>array2</parameter></paramdef>
- <paramdef>
+ <paramdef>array
<parameter><optional> ...</optional></parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>
- <function>array_merge</function> merges the elements of two or
+ <function>Array_merge</function> merges the elements of two or
more arrays together so that the values of one are appended to
the end of the previous one. It returns the resulting array.
</para>
@@ -319,13 +294,13 @@
<funcdef>array <function>array_merge_recursive</function></funcdef>
<paramdef>array <parameter>array1</parameter></paramdef>
<paramdef>array <parameter>array2</parameter></paramdef>
- <paramdef>
+ <paramdef>array
<parameter><optional> ...</optional></parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
<para>
- <function>array_merge_recursive</function> merges the elements of
+ <function>Array_merge_recursive</function> merges the elements of
two or more arrays together so that the values of one are appended
to the end of the previous one. It returns the resulting array.
</para>
@@ -339,11 +314,11 @@
</para>
<para>
<example>
- <title><function>array_merge_recursive</function> example</title>
+ <title><function>Array_merge_recursive</function> example</title>
<programlisting role="php">
-$ar1 = array("color" => array("favorite" => "red"), 5);
-$ar2 = array(10, "color" => array("favorite" => "green", "blue"));
-$result = array_merge_recursive($ar1, $ar2);
+$ar1 = array ("color" => array ("favorite" => "red"), 5);
+$ar2 = array (10, "color" => array ("favorite" => "green", "blue"));
+$result = array_merge_recursive ($ar1, $ar2);
</programlisting>
<para>
Resulting array will be array("color" => array("favorite" =>
@@ -371,17 +346,19 @@
<paramdef>mixed
<parameter><optional>arg</optional></parameter>
</paramdef>
- <paramdef>
+ <paramdef>mixed
<parameter><optional>...</optional></parameter>
</paramdef>
+ <paramdef>array
+ <parameter><optional>...</optional></parameter>
+ </paramdef>
</funcprototype>
</funcsynopsis>
<para>
- <function>array_multisort</function> can be used to sort several
+ <function>Array_multisort</function> can be used to sort several
arrays at once or a multi-dimensional array according by one of
more dimensions. It maintains key association when sorting.
</para>
-
<para>
The input arrays are treated as columns of a table to be sorted
by rows - this resembles the functionality of SQL ORDER BY
@@ -389,14 +366,12 @@
(values) in that array that compare the same are sorted by the
next input array, and so on.
</para>
-
<para>
The argument structure of this function is a bit unusual, but
flexible. The very first argument has to be an
array. Subsequently, each argument can be either an array or a
sorting flag from the following lists.
</para>
-
<para>
Sorting order flags:
<itemizedlist>
@@ -408,7 +383,6 @@
</listitem>
</itemizedlist>
</para>
-
<para>
Sorting type flags:
<itemizedlist>
@@ -423,24 +397,21 @@
</listitem>
</itemizedlist>
</para>
-
<para>
No two sorting flags of the same type can be specified after each
array. The sortings flags specified after an array argument apply
only to that array - they are reset to default SORT_ASC and
SORT_REGULAR after before each new array argument.
</para>
-
<para>
Returns true on success, false on failure.
</para>
-
<example>
<title>Sorting multiple arrays</title>
<programlisting role="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>
<para>
In this example, after sorting, the first array will contain 10,
@@ -449,12 +420,12 @@
entries in the first array (100 and 100) were sorted as well.
</para>
</example>
-
<example>
<title>Sorting multi-dimensional array</title>
<programlisting role="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>
<para>
In this example, after sorting, the first array will contain 10,
@@ -484,7 +455,7 @@
</funcprototype>
</funcsynopsis>
<para>
- <function>array_pad</function> returns a copy of the
+ <function>Array_pad</function> returns a copy of the
<parameter>input</parameter> padded to size specified by
<parameter>pad_size</parameter> with value
<parameter>pad_value</parameter>. If
@@ -496,7 +467,7 @@
</para>
<para>
<example>
- <title><function>array_pad</function> example</title>
+ <title><function>Array_pad</function> example</title>
<programlisting role="php">
$input = array (12, 10, 9);
@@ -528,20 +499,21 @@
</funcprototype>
</funcsynopsis>
<para>
- <function>array_pop</function> pops and returns the last value of
+ <function>Array_pop</function> pops and returns the last value of
the <parameter>array</parameter>, shortening the
<parameter>array</parameter> by one element.
</para>
<para>
<example>
- <title><function>array_pop</function> example</title>
+ <title><function>Array_pop</function> example</title>
<programlisting role="php">
$stack = array ("orange", "apple", "raspberry");
$fruit = array_pop ($stack);
</programlisting>
<para>
- After this, $stack has only 2 elements: "orange" and "apple",
- and $fruit has "raspberry".
+ After this, <varname>$stack</varname> has only 2 elements:
+ "orange" and "apple", and <varname>$fruit</varname> has
+ "raspberry".
</para>
</example>
</para>
@@ -549,11 +521,6 @@
See also <function>array_push</function>,
<function>array_shift</function>, and
<function>array_unshift</function>.
- <note>
- <para>
- This function was added in PHP 4.0.
- </para>
- </note>
</para>
</refsect1>
</refentry>
@@ -579,7 +546,7 @@
</funcsynopsis>
<para>
- <function>array_push</function> treats
+ <function>Array_push</function> treats
<parameter>array</parameter> as a stack, and pushes the passed
variables onto the end of <parameter>array</parameter>. The
length of <parameter>array</parameter> increases by the number of
@@ -594,24 +561,19 @@
</para>
<para>
<example>
- <title><function>array_push</function> example</title>
+ <title><function>Array_push</function> example</title>
<programlisting role="php">
$stack = array (1, 2);
-array_push($stack, "+", 3);
+array_push ($stack, "+", 3);
</programlisting>
</example>
- This example would result in $stack having 4 elements: 1, 2, "+",
- and 3.
+ This example would result in <varname>$stack</varname> having 4
+ elements: 1, 2, "+", and 3.
</para>
<para>
See also: <function>array_pop</function>,
<function>array_shift</function>, and
<function>array_unshift</function>.
- <note>
- <para>
- This function was added in PHP 4.0.
- </para>
- </note>
</para>
</refsect1>
</refentry>
@@ -619,7 +581,9 @@
<refentry id="function.array-rand">
<refnamediv>
<refname>array_rand</refname>
- <refpurpose>Pick one or more random entries out of an array</refpurpose>
+ <refpurpose>
+ Pick one or more random entries out of an array
+ </refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
@@ -633,32 +597,29 @@
</funcprototype>
</funcsynopsis>
<para>
- <function>array_rand</function> is rather useful when you want to
+ <function>Array_rand</function> is rather useful when you want to
pick one or more random entries out of an array. It takes an
<parameter>input</parameter> array and an optional argument
<parameter>num_req</parameter> which specifies how many entries you
want to pick - if not specified, it defaults to 1.
</para>
-
<para>
If you are picking only one entry, <function>array_rand</function>
returns the key for a random entry. Otherwise, it returns an array
of keys for the random entries. This is done so that you can pick
random keys as well as values out of the array.
</para>
-
<para>
Don't forget to call <function>srand</function> to seed the random
number generator.
</para>
-
<para>
<example>
- <title><function>array_rand</function> example</title>
+ <title><function>Array_rand</function> example</title>
<programlisting role="php">
-srand((double)microtime() * 10000000);
-$input = array("Neo", "Morpheus", "Trinity", "Cypher", "Tank");
-$rand_keys = array_rand($input, 2);
+srand ((double) microtime() * 10000000);
+$input = array ("Neo", "Morpheus", "Trinity", "Cypher", "Tank");
+$rand_keys = array_rand ($input, 2);
print $input[$rand_keys[0]]."\n";
print $input[$rand_keys[1]]."\n";
</programlisting>
@@ -683,24 +644,19 @@
</funcprototype>
</funcsynopsis>
<para>
- <function>array_reverse</function> takes input
+ <function>Array_reverse</function> takes input
<parameter>array</parameter> and returns a new array with the
order of the elements reversed.
</para>
<para>
<example>
- <title><function>array_reverse</function> example</title>
+ <title><function>Array_reverse</function> example</title>
<programlisting role="php">
$input = array ("php", 4.0, array ("green", "red"));
$result = array_reverse ($input);
</programlisting>
</example>
This makes $result have array (array ("green", "red"), 4.0, "php").
- <note>
- <para>
- This function was added in PHP 4.0 Beta 3.
- </para>
- </note>
</para>
</refsect1>
</refentry>
@@ -721,31 +677,26 @@
</funcprototype>
</funcsynopsis>
<para>
- <function>array_shift</function> shifts the first value of the
+ <function>Array_shift</function> shifts the first value of the
<parameter>array</parameter> off and returns it, shortening the
<parameter>array</parameter> by one element and moving everything
down.
</para>
<para>
<example>
- <title><function>array_shift</function> example</title>
+ <title><function>Array_shift</function> example</title>
<programlisting role="php">
$args = array ("-v", "-f");
$opt = array_shift ($args);
</programlisting>
</example>
- This would result in $args having one element "-f" left, and $opt
- being "-v".
+ This would result in <varname>$args</varname> having one element
+ "-f" left, and <varname>$opt</varname> being "-v".
</para>
<para>
See also <function>array_unshift</function>,
<function>array_push</function>, and
<function>array_pop</function>.
- <note>
- <para>
- This function was added in PHP 4.0.
- </para>
- </note>
</para>
</refsect1>
</refentry>
@@ -770,7 +721,7 @@
</funcprototype>
</funcsynopsis>
<para>
- <function>array_slice</function> returns a sequence of elements
+ <function>Array_slice</function> returns a sequence of elements
from the <parameter>array</parameter> specified by the
<parameter>offset</parameter> and <parameter>length</parameter>
parameters.
@@ -792,7 +743,7 @@
</para>
<para>
<example>
- <title><function>array_slice</function> examples</title>
+ <title><function>Array_slice</function> examples</title>
<programlisting role="php">
$input = array ("a", "b", "c", "d", "e");
@@ -805,11 +756,6 @@
</para>
<para>
See also <function>array_splice</function>.
- <note>
- <para>
- This function was added in PHP 4.0.
- </para>
- </note>
</para>
</refsect1>
</refentry>
@@ -840,7 +786,7 @@
</funcprototype>
</funcsynopsis>
<para>
- <function>array_splice</function> removes the elements designated
+ <function>Array_splice</function> removes the elements designated
by <parameter>offset</parameter> and
<parameter>length</parameter> from the
<parameter>input</parameter> array, and replaces them with the
@@ -881,11 +827,12 @@
<para>
The following equivalences hold:
<programlisting role="php">
-array_push($input, $x, $y) array_splice($input, count($input), 0, array($x, $y))
-array_pop($input) array_splice($input, -1)
-array_shift($input) array_splice($input, 0, 1)
-array_unshift($input, $x, $y) array_splice($input, 0, 0, array($x, $y))
-$a[$x] = $y array_splice($input, $x, 1, $y)
+array_push ($input, $x, $y) array_splice ($input, count ($input), 0,
+ array ($x, $y))
+array_pop ($input) array_splice ($input, -1)
+array_shift ($input) array_splice ($input, 0, 1)
+array_unshift ($input, $x, $y) array_splice ($input, 0, 0, array ($x, $y))
+$a[$x] = $y array_splice ($input, $x, 1, $y)
</programlisting>
</para>
<para>
@@ -893,27 +840,22 @@
</para>
<para>
<example>
- <title><function>array_splice</function> examples</title>
+ <title><function>Array_splice</function> examples</title>
<programlisting role="php">
-$input = array("red", "green", "blue", "yellow");
+$input = array ("red", "green", "blue", "yellow");
-array_splice($input, 2); // $input is now array("red", "green")
-array_splice($input, 1, -1); // $input is now array("red", "yellow")
-array_splice($input, 1, count($input), "orange");
- // $input is now array("red", "orange")
-array_splice($input, -1, 1, array("black", "maroon"));
- // $input is now array("red", "green",
- // "blue", "black", "maroon")
+array_splice ($input, 2); // $input is now array ("red", "green")
+array_splice ($input, 1, -1); // $input is now array ("red", "yellow")
+array_splice ($input, 1, count($input), "orange");
+ // $input is now array ("red", "orange")
+array_splice ($input, -1, 1, array("black", "maroon"));
+ // $input is now array ("red", "green",
+ // "blue", "black", "maroon")
</programlisting>
</example>
</para>
<para>
See also <function>array_slice</function>.
- <note>
- <para>
- This function was added in PHP 4.0.
- </para>
- </note>
</para>
</refsect1>
</refentry>
@@ -932,13 +874,13 @@
</funcprototype>
</funcsynopsis>
<para>
- <function>array_unique</function> takes input
+ <function>Array_unique</function> takes input
<parameter>array</parameter> and returns a new array
without duplicate values.
</para>
<para>
<example>
- <title><function>array_unique</function> example</title>
+ <title><function>Array_unique</function> example</title>
<programlisting role="php">
$input = array ("a" => "green", "red", "b" => "green", "blue", "red");
$result = array_unique ($input);
@@ -948,21 +890,15 @@
</para>
</example>
</para>
- <para>
- <note>
- <para>
- This function was added in PHP 4.0.1.
- </para>
- </note>
- </para>
</refsect1>
</refentry>
<refentry id="function.array-unshift">
<refnamediv>
<refname>array_unshift</refname>
- <refpurpose>Push one or more elements
- onto the beginning of array</refpurpose>
+ <refpurpose>
+ Push one or more elements onto the beginning of array
+ </refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
@@ -971,7 +907,7 @@
<funcdef>int <function>array_unshift</function></funcdef>
<paramdef>array <parameter>array</parameter></paramdef>
<paramdef>mixed <parameter>var</parameter></paramdef>
- <paramdef>
+ <paramdef>mixed
<parameter>
<optional>...</optional>
</parameter>
@@ -979,7 +915,7 @@
</funcprototype>
</funcsynopsis>
<para>
- <function>array_unshift</function> prepends passed elements to
+ <function>Array_unshift</function> prepends passed elements to
the front of the <parameter>array</parameter>. Note that the list
of elements is prepended as a whole, so that the prepended
elements stay in the same order.
@@ -992,8 +928,8 @@
<example>
<title><function>array_unshift</function> example</title>
<programlisting role="php">
-$queue = array("p1", "p3");
-array_unshift($queue, "p4", "p5", "p6");
+$queue = array ("p1", "p3");
+array_unshift ($queue, "p4", "p5", "p6");
</programlisting>
</example>
This would result in $queue having 5 elements: "p4", "p5", "p6",
@@ -1003,11 +939,6 @@
See also <function>array_shift</function>,
<function>array_push</function>, and
<function>array_pop</function>.
- <note>
- <para>
- This function was added in PHP 4.0.
- </para>
- </note>
</para>
</refsect1>
</refentry>
@@ -1026,22 +957,17 @@
</funcprototype>
</funcsynopsis>
<para>
- <function>array_values</function> returns all the values from the
+ <function>Array_values</function> returns all the values from the
<parameter>input</parameter> array.
</para>
<para>
<example>
- <title><function>array_values</function> example</title>
+ <title><function>Array_values</function> example</title>
<programlisting role="php">
-$array = array("size" => "XL", "color" => "gold");
-array_values($array); // returns array("XL", "gold")
+$array = array ("size" => "XL", "color" => "gold");
+array_values ($array); // returns array ("XL", "gold")
</programlisting>
</example>
- <note>
- <para>
- This function was added in PHP 4.0.
- </para>
- </note>
</para>
</refsect1>
</refentry>
@@ -1050,7 +976,7 @@
<refnamediv>
<refname>array_walk</refname>
<refpurpose>
- Apply a user function to every member of an array.
+ Apply a user function to every member of an array
</refpurpose>
</refnamediv>
<refsect1>
@@ -1102,7 +1028,7 @@
</note>
<para>
<example>
- <title><function>array_walk</function> example</title>
+ <title><function>Array_walk</function> example</title>
<programlisting role="php">
$fruits = array ("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple");
@@ -1149,13 +1075,13 @@
with. This is used mainly when sorting associative arrays where
the actual element order is significant.
<example>
- <title><function>arsort</function> example</title>
+ <title><function>Arsort</function> example</title>
<programlisting role="php">
$fruits = array ("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple");
arsort ($fruits);
-reset($fruits);
-while(list($key,$val)=each($fruits)) {
- echo "$key = $val\n";
+reset ($fruits);
+while (list ($key, $val) = each ($fruits)) {
+ echo "$key = $val\n";
}
</programlisting>
</example>
@@ -1195,13 +1121,13 @@
with. This is used mainly when sorting associative arrays where
the actual element order is significant.
<example>
- <title><function>asort</function> example</title>
+ <title><function>Asort</function> example</title>
<programlisting role="php">
$fruits = array ("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple");
asort ($fruits);
-reset($fruits);
-while(list($key,$val)=each($fruits)) {
- echo "$key = $val\n";
+reset ($fruits);
+while (list ($key, $val) = each ($fruits)) {
+ echo "$key = $val\n";
}
</programlisting>
</example>
@@ -1234,16 +1160,14 @@
<funcsynopsis>
<funcprototype>
<funcdef>array <function>compact</function></funcdef>
- <paramdef><parameter>string varname | array
- varnames</parameter></paramdef>
- <paramdef>
+ <paramdef>mixed <parameter>varname</parameter></paramdef>
+ <paramdef>mixed
<parameter><optional>...</optional></parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
-
<para>
- <function>compact</function> takes a variable number of
+ <function>Compact</function> takes a variable number of
parameters. Each parameter can be either a string containing the
name of the variable, or an array of variable names. The array
can contain other arrays of variable names inside it;
@@ -1259,7 +1183,7 @@
</para>
<para>
<example>
- <title><function>compact</function> example</title>
+ <title><function>Compact</function> example</title>
<programlisting role="php">
$city = "San Francisco";
$state = "CA";
@@ -1270,18 +1194,13 @@
$result = compact ("event", $location_vars);
</programlisting>
<para>
- After this, $result will be array ("event" => "SIGGRAPH",
- "city" => "San Francisco", "state" => "CA").
+ After this, <varname>$result</varname> will be array ("event"
+ => "SIGGRAPH", "city" => "San Francisco", "state" => "CA").
</para>
</example>
</para>
<para>
See also <function>extract</function>.
- <note>
- <para>
- This function was added in PHP 4.0.
- </para>
- </note>
</para>
</refsect1>
</refentry>
@@ -1289,7 +1208,7 @@
<refentry id="function.count">
<refnamediv>
<refname>count</refname>
- <refpurpose>count elements in a variable</refpurpose>
+ <refpurpose>Count elements in a variable</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
@@ -1311,7 +1230,7 @@
Returns 0 if the variable is not set.
<warning>
<para>
- <function>count</function> may return 0 for a variable that
+ <function>Count</function> may return 0 for a variable that
isn't set, but it may also return 0 for a variable that has
been initialized with an empty array. Use
<function>isset</function> to test if a variable is set.
@@ -1350,7 +1269,6 @@
pointer. It does not move the pointer in any way. If the
internal pointer points beyond the end of the elements list,
<function>current</function> returns false.
-
<warning>
<para>
If the array contains empty elements (0 or "", the empty
@@ -1365,7 +1283,7 @@
</para>
<para>
See also: <function>end</function>, <function>next</function>,
- <function>prev</function> and <function>reset</function>.
+ <function>prev</function>, and <function>reset</function>.
</para>
</refsect1>
</refentry>
@@ -1402,13 +1320,13 @@
</para>
<para>
<example>
- <title><function>each</function> examples</title>
+ <title><function>Each</function> examples</title>
<programlisting role="php">
$foo = array ("bob", "fred", "jussi", "jouni", "egon", "marliese");
$bar = each ($foo);
</programlisting>
<para>
- <literal>$bar</literal> now contains the following key/value
+ <varname>$bar</varname> now contains the following key/value
pairs:
<itemizedlist spacing="compact">
<listitem><simpara>0 => 0</simpara></listitem>
@@ -1423,7 +1341,7 @@
</programlisting>
</para>
<para>
- <literal>$bar</literal> now contains the following key/value
+ <varname>$bar</varname> now contains the following key/value
pairs:
<itemizedlist spacing="compact">
<listitem><simpara>0 => 'Robert'</simpara></listitem>
@@ -1434,14 +1352,14 @@
</para>
</example>
</para>
-
<para>
- <function>each</function> is typically used in conjunction with
+ <function>Each</function> is typically used in conjunction with
<function>list</function> to traverse an array; for instance,
- $HTTP_POST_VARS:
+ <varname>$HTTP_POST_VARS</varname>:
<example>
<title>
- Traversing $HTTP_POST_VARS with <function>each</function>
+ Traversing <varname>$HTTP_POST_VARS</varname> with
+ <function>each</function>
</title>
<programlisting role="php">
echo "Values submitted via POST method:<br>";
@@ -1452,7 +1370,6 @@
</programlisting>
</example>
</para>
-
<para>
After <function>each</function> has executed, the array cursor
will be left on the next element of the array, or on the last
@@ -1482,7 +1399,7 @@
</funcprototype>
</funcsynopsis>
<para>
- <function>end</function> advances <parameter>array</parameter>'s
+ <function>End</function> advances <parameter>array</parameter>'s
internal pointer to the last element.
</para>
<para>
@@ -1524,7 +1441,7 @@
<parameter>prefix</parameter> parameters.
</para>
<para>
- <function>extract</function> checks for colissions with existing
+ <function>Extract</function> checks for colissions with existing
variables. The way collisions are treated is determined by
<parameter>extract_type</parameter>. It can be one of the
following values:
@@ -1574,7 +1491,7 @@
EXTR_PREFIX_ALL.
</para>
<para>
- <function>extract</function> checks each key to see if it
+ <function>Extract</function> checks each key to see if it
constitues a valid variable name, and if it does only then does
it proceed to import it.
</para>
@@ -1611,12 +1528,15 @@
</programlisting>
</para>
<para>
- The $size wasn't overwritten, becaus we specified
- EXTR_PREFIX_SAME, which resulted in $wddx_size being created.
- If EXTR_SKIP was specified, then $wddx_size wouldn't even have
- been created. EXTR_OVERWRITE would have cause $size to have
- value "medium", and EXTR_PREFIX_ALL would result in new
- variables being named $wddx_color, $wddx_size, and $wddx_shape.
+ The <varname>$size</varname> wasn't overwritten, becaus we
+ specified EXTR_PREFIX_SAME, which resulted in
+ <varname>$wddx_size</varname> being created. If EXTR_SKIP was
+ specified, then $wddx_size wouldn't even have been created.
+ EXTR_OVERWRITE would have cause <varname>$size</varname> to have
+ value "medium", and EXTR_PREFIX_ALL would result in new variables
+ being named <varname>$wddx_color</varname>,
+ <varname>$wddx_size</varname>, and
+ <varname>$wddx_shape</varname>.
</para>
</refsect1>
</refentry>
@@ -1642,18 +1562,13 @@
</para>
<para>
<example>
- <title><function>in_array</function> example</title>
+ <title><function>In_array</function> example</title>
<programlisting role="php">
$os = array ("Mac", "NT", "Irix", "Linux");
if (in_array ("Irix", $os))
print "Got Irix";
</programlisting>
</example>
- <note>
- <para>
- This function was added in PHP 4.0.
- </para>
- </note>
</para>
</refsect1>
</refentry>
@@ -1672,11 +1587,11 @@
</funcprototype>
</funcsynopsis>
<para>
- <function>key</function> returns the index element of the
+ <function>Key</function> returns the index element of the
current array position.
</para>
<para>
- See also: <function>current</function>, <function>next</function>
+ See also <function>current</function> and <function>next</function>.
</para>
</refsect1>
</refentry>
@@ -1698,13 +1613,13 @@
Sorts an array by key in reverse order, maintaining key to data
correlations. This is useful mainly for associative arrays.
<example>
- <title><function>krsort</function> example</title>
+ <title><function>Krsort</function> example</title>
<programlisting role="php">
$fruits = array ("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple");
krsort ($fruits);
-reset($fruits);
-while(list($key,$val)=each($fruits)) {
- echo "$key -> $val\n";
+reset ($fruits);
+while (list ($key, $val) = each ($fruits)) {
+ echo "$key -> $val\n";
}
</programlisting>
</example>
@@ -1741,13 +1656,13 @@
Sorts an array by key, maintaining key to data correlations. This
is useful mainly for associative arrays.
<example>
- <title><function>ksort</function> example</title>
+ <title><function>Ksort</function> example</title>
<programlisting role="php">
$fruits = array ("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple");
ksort ($fruits);
-reset($fruits);
-while(list($key,$val)=each($fruits)) {
- echo "$key -> $val\n";
+reset ($fruits);
+while (list ($key, $val) = each ($fruits)) {
+ echo "$key -> $val\n";
}
</programlisting>
</example>
@@ -1796,12 +1711,12 @@
<?php
-$result = mysql($conn, "SELECT id, name, salary FROM employees");
-while (list($id, $name, $salary) = mysql_fetch_row($result)) {
- print(" <tr>\n".
- " <td><a href=\"info.php3?id=$id\">$name</a></td>\n".
- " <td>$salary</td>\n".
- " </tr>\n");
+$result = mysql ($conn, "SELECT id, name, salary FROM employees");
+while (list ($id, $name, $salary) = mysql_fetch_row ($result)) {
+ print (" <tr>\n".
+ " <td><a href=\"info.php3?id=$id\">$name</a></td>\n".
+ " <td>$salary</td>\n".
+ " </tr>\n");
}
?>
@@ -1811,7 +1726,7 @@
</example>
</para>
<para>
- See also: <function>each</function>, <function>array</function>.
+ See also <function>each</function> and <function>array</function>.
</para>
</refsect1>
</refentry>
@@ -1836,7 +1751,7 @@
internal array pointer, or false if there are no more elements.
</para>
<para>
- <function>next</function> behaves like
+ <function>Next</function> behaves like
<function>current</function>, with one difference. It advances
the internal array pointer one place forward before returning the
element. That means it returns the next array element and
@@ -1854,8 +1769,8 @@
</para>
<para>
See also:
- <function>current</function>, <function>end</function>
- <function>prev</function> and <function>reset</function>
+ <function>current</function>, <function>end</function>,
+ <function>prev</function>, and <function>reset</function>.
</para>
</refsect1>
</refentry>
@@ -1911,13 +1826,13 @@
</warning>
</para>
<para>
- <function>prev</function> behaves just like
+ <function>Prev</function> behaves just like
<function>next</function>, except it rewinds the internal array
pointer one place instead of advancing it.
</para>
<para>
- See also: <function>current</function>, <function>end</function>
- <function>next</function> and <function>reset</function>
+ See also: <function>current</function>, <function>end</function>,
+ <function>next</function>, and <function>reset</function>.
</para>
</refsect1>
</refentry>
@@ -1939,7 +1854,7 @@
</funcprototype>
</funcsynopsis>
<para>
- <function>range</function> returns an array of integers from
+ <function>Range</function> returns an array of integers from
<parameter>low</parameter> to <parameter>high</parameter>,
inclusive.
</para>
@@ -1965,11 +1880,11 @@
</funcprototype>
</funcsynopsis>
<para>
- <function>reset</function> rewinds <parameter>array</parameter>'s
+ <function>Reset</function> rewinds <parameter>array</parameter>'s
internal pointer to the first element.
</para>
<para>
- <function>reset</function> returns the value of the first array
+ <function>Reset</function> returns the value of the first array
element.
</para>
<para>
@@ -1996,13 +1911,13 @@
<para>
This function sorts an array in reverse order (highest to lowest).
<example>
- <title><function>rsort</function> example</title>
+ <title><function>Rsort</function> example</title>
<programlisting role="php">
$fruits = array ("lemon", "orange", "banana", "apple");
rsort ($fruits);
-reset($fruits);
-while(list($key,$val)=each($fruits)) {
- echo "$key -> $val\n";
+reset ($fruits);
+while (list ($key, $val) = each ($fruits)) {
+ echo "$key -> $val\n";
}
</programlisting>
</example>
@@ -2040,12 +1955,12 @@
This function shuffles (randomizes the order of the elements in)
an array.
<example>
- <title><function>shuffle</function> example</title>
+ <title><function>Shuffle</function> example</title>
<programlisting role="php">
$numbers = range (1,20);
srand (time());
shuffle ($numbers);
-while (list(, $number) = each ($numbers)) {
+while (list (, $number) = each ($numbers)) {
echo "$number ";
}
</programlisting>
@@ -2076,7 +1991,7 @@
Returns the number of elements in the array.
</para>
<para>
- See also: <function>count</function>
+ See also <function>count</function>.
</para>
</refsect1>
</refentry>
@@ -2098,13 +2013,13 @@
This function sorts an array. Elements will be arranged from
lowest to highest when this function has completed.
<example>
- <title><function>sort</function> example</title>
+ <title><function>Sort</function> example</title>
<programlisting role="php">
$fruits = array ("lemon", "orange", "banana", "apple");
sort ($fruits);
-reset($fruits);
-while(list($key,$val)=each($fruits)) {
- echo "$key -> $val\n";
+reset ($fruits);
+while (list ($key, $val) = each ($fruits)) {
+ echo "$key -> $val\n";
}
</programlisting>
</example>
@@ -2175,7 +2090,7 @@
this function.
<example>
- <title><function>uksort</function> example</title>
+ <title><function>Uksort</function> example</title>
<programlisting role="php">
function mycompare ($a, $b) {
if ($a == $b) return 0;
@@ -2218,7 +2133,7 @@
<funcprototype>
<funcdef>void <function>usort</function></funcdef>
<paramdef>array <parameter>array</parameter></paramdef>
- <paramdef>function <parameter>cmp_function</parameter></paramdef>
+ <paramdef>string <parameter>cmp_function</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
@@ -2234,7 +2149,7 @@
second. If two members compare as equal, their order in the
sorted array is undefined.
<example>
- <title><function>usort</function> example</title>
+ <title><function>Usort</function> example</title>
<programlisting role="php">
function cmp ($a, $b) {
if ($a == $b) return 0;
@@ -2272,7 +2187,7 @@
<para>
See also: <function>arsort</function>,
<function>asort</function>, <function>ksort</function>,
- <function>rsort</function> and <function>sort</function>.
+ <function>rsort</function>, and <function>sort</function>.
</para>
</refsect1>
</refentry>
- Next message: Martin Samesch: "[PHP-DOC] cvs: phpdoc /en/functions mssql.xml"
- Previous message: Jani Taskinen: "[PHP-DOC] cvs: phpdoc /en/functions ldap.xml"
- Next in thread: Egon Schmid: "[PHP-DOC] cvs: phpdoc /en/functions array.xml"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

