Index: phpdoc/en/functions/array.xml
diff -u phpdoc/en/functions/array.xml:1.95 phpdoc/en/functions/array.xml:1.96
--- phpdoc/en/functions/array.xml:1.95 Sat Sep 15 15:06:11 2001
+++ phpdoc/en/functions/array.xml Sat Sep 15 19:47:44 2001
@@ -1,5 +1,5 @@
-
+
Array FunctionsArrays
@@ -91,8 +91,7 @@
which will display :
-Array
-(
+Array (
[0] => 1
[1] => 1
[2] => 1
@@ -112,15 +111,14 @@
1-based index with array
- $firstquarter = array(1 => 'January', 'February', 'March');
- print_r($firstquarter);
+$firstquarter = array(1 => 'January', 'February', 'March');
+print_r($firstquarter);
which will display :
-Array
-(
+Array (
[1] => 'January'
[2] => 'February'
[3] => 'March'
@@ -225,7 +223,9 @@
array_filter
- Filters elements of an array using a callback function
+
+ Filters elements of an array using a callback function
+ Description
@@ -250,11 +250,11 @@
array_filter example
function odd($var) {
- return ($var % 2 == 1);
+ return ($var % 2 == 1);
}
function even($var) {
- return ($var % 2 == 0);
+ return ($var % 2 == 0);
}
$array1 = array ("a"=>1, "b"=>2, "c"=>3, "d"=>4, "e"=>5);
@@ -434,18 +434,19 @@
those still using PHP 3.
- Implementation of array_keys for PHP 3
- users
+ Implementation of array_keys for PHP 3
+ users
function array_keys ($arr, $term="") {
$t = array();
while (list($k,$v) = each($arr)) {
- if ($term && $v != $term)
+ if ($term && $v != $term) {
continue;
$t[] = $k;
}
return $t;
+ }
}
@@ -460,7 +461,9 @@
array_map
- Applies the callback to the elements of the given arrays
+
+ Applies the callback to the elements of the given arrays
+ Description
@@ -475,18 +478,18 @@
- array_map returns an array
- containing all the elements of arr1
- after applying the callback function to each one.
- The number of parameters that the callback function accepts should
- match the number of arrays passed to the array_map
+ array_map returns an array containing all
+ the elements of arr1 after applying the
+ callback function to each one. The number of parameters that the
+ callback function accepts should match the number of arrays
+ passed to the array_maparray_map example
function cube($n) {
- return $n*$n*$n;
+ return $n*$n*$n;
}
$a = array(1, 2, 3, 4, 5);
@@ -503,11 +506,11 @@
array_map - using more arrays
function show_Spanish($n, $m) {
- return "The number $n is called $m in Spanish";
+ return "The number $n is called $m in Spanish";
}
function map_Spanish($n, $m) {
- return array ($n => $m);
+ return array ($n => $m);
}
$a = array(1, 2, 3, 4, 5);
@@ -518,8 +521,7 @@
print_r($c);
// will output:
-// Array
-// (
+// Array (
// [0] => The number 1 is called uno in Spanish
// [1] => The number 2 is called dos in Spanish
// [2] => The number 3 is called tres in Spanish
@@ -532,8 +534,7 @@
print_r($d);
// will output:
-// Array
-// (
+// Array (
// [0] => Array
// (
// [1] => uno
@@ -577,7 +578,7 @@
- array_map - creating an array of arrays
+ Creating an array of arrays
$a = array(1, 2, 3, 4, 5);
$b = array("one", "two", "three", "four", "five");
@@ -1050,7 +1051,9 @@
array array_reversearray array
- bool preserve_keys
+ bool
+ preserve_keys
+
@@ -1070,8 +1073,9 @@
- This makes both $result and $result_keyed
- be array(array ("green", "red"), 4.0, "php"). But
+ This makes both $result and
+ $result_keyed be array(array
+ ("green", "red"), 4.0, "php"). But
$result_keyed[0] is still
"php".
@@ -1087,7 +1091,8 @@
array_reduce
- Iteratively reduce the array to a single value using a callback function
+ Iteratively reduce the array to a single value using a callback
+ function
@@ -1103,7 +1108,7 @@
- array_reduce applies iteratively the
+ array_reduce applies iteratively the
callback function to the elements of the
array input, so as to reduce the array to
a single value. If the optional intial is
@@ -1115,13 +1120,13 @@
array_reduce example
function rsum($v, $w) {
- $v += $w;
- return $v;
+ $v += $w;
+ return $v;
}
function rmul($v, $w) {
- $v *= $w;
- return $v;
+ $v *= $w;
+ return $v;
}
$a = array(1, 2, 3, 4, 5);
@@ -1135,8 +1140,8 @@
This will result in $b containing
15, $c containing
- 1200 (= 1*2*3*4*5*10), and $d
- containing 1.
+ 1200 (= 1*2*3*4*5*10), and
+ $d containing 1.
See also array_filter,
@@ -1164,9 +1169,8 @@
array_shift shifts the first value of the
array off and returns it, shortening the
array by one element and moving everything
- down.
- If array is empty (or is not an array),
- &null; will be returned.
+ down. If array is empty (or is not an
+ array), &null; will be returned.
@@ -1314,7 +1318,7 @@
The following equivalences hold:
-
+
array_push ($input, $x, $y) array_splice ($input, count ($input), 0,
array ($x, $y))
array_pop ($input) array_splice ($input, -1)
@@ -1378,7 +1382,7 @@
array_sum examples
-$a = array(2,4,6,8);
+$a = array(2, 4, 6, 8);
echo "sum(a) = ".array_sum($a)."\n";
// prints: sum(a) = 20
@@ -1554,8 +1558,8 @@
those still using PHP 3.
- Implementation of array_values for PHP 3
- users
+ Implementation of array_values for PHP 3
+ users
function array_values ($arr) {
@@ -1735,7 +1739,9 @@
void asortarray array
- int sort_flags
+ int
+ sort_flags
+
@@ -1833,8 +1839,9 @@
$result = compact ("event", "nothing_here", $location_vars);
- After this, $result will be array ("event"
- => "SIGGRAPH", "city" => "San Francisco", "state" => "CA").
+ After this, $result will be array
+ ("event" => "SIGGRAPH", "city" => "San Francisco",
+ "state" => "CA").
@@ -1876,9 +1883,9 @@
- Please see the Arrays
- section of the manual for a detailed explanation of how arrays are
- implemented and used in PHP.
+ Please see the Arrays
+ section of the manual for a detailed explanation of how arrays
+ are implemented and used in PHP.
@@ -1960,7 +1967,8 @@
each
- Return the current key and value pair from an array and advance the array cursor
+ Return the current key and value pair from an array and advance
+ the array cursor
@@ -2115,10 +2123,11 @@
- extract checks each key to see whether if constitutes
- a valid variable name and also for collisions with existing variables in
- the symbol table. The way invalid/numeric keys and collisions are treated
- is determined by extract_type. It can be one of the
+ extract checks each key to see whether if
+ constitutes a valid variable name and also for collisions with
+ existing variables in the symbol table. The way invalid/numeric
+ keys and collisions are treated is determined by
+ extract_type. It can be one of the
following values:
@@ -2150,8 +2159,9 @@
EXTR_PREFIX_ALL
- Prefix all variable names with prefix. Since PHP
- 4.0.5 this includes numeric ones as well.
+ Prefix all variable names with
+ prefix. Since PHP 4.0.5 this includes
+ numeric ones as well.
@@ -2160,7 +2170,8 @@
Only prefix invalid/numeric variable names with
- prefix. This flag has been added in PHP 4.0.5.
+ prefix. This flag has been added in
+ PHP 4.0.5.
@@ -2172,13 +2183,14 @@
Note that prefix is only required if
- extract_type is EXTR_PREFIX_SAME, EXTR_PREFIX_ALL,
- or EXTR_PREFIX_INVALID. If the prefixed result is not a valid variable
- name, it is not imported into the symbol table.
+ extract_type is EXTR_PREFIX_SAME,
+ EXTR_PREFIX_ALL, or EXTR_PREFIX_INVALID. If the prefixed result
+ is not a valid variable name, it is not imported into the symbol
+ table.
- extract returns the number of variables successfully
- imported into the symbol table.
+ extract returns the number of variables
+ successfully imported into the symbol table.
A possible use for extract is to import into symbol table
@@ -2266,9 +2278,9 @@
in_array example
$os = array ("Mac", "NT", "Irix", "Linux");
-if (in_array ("Irix", $os)){
+if (in_array ("Irix", $os)) {
print "Got Irix";
- }
+}
@@ -2301,7 +2313,8 @@
array_search
- Searches the array for a given value and returns the corresponding key if successful
+ Searches the array for a given value and returns the
+ corresponding key if successful
@@ -2549,8 +2562,8 @@
natsort example
-$array1 = $array2 = array ("img12.png","img10.png","img2.png","img1.png");
-
+$array1 = $array2 = array ("img12.png", "img10.png", "img2.png", "img1.png");
+
sort($array1);
echo "Standard sorting\n";
print_r($array1);
@@ -2586,7 +2599,7 @@
)
- For more infomation see: Martin Pool's Natural Order String Comparison
page.
@@ -2765,29 +2778,29 @@
range returns an array of elements from
low to high,
- inclusive. If low > high, the sequence will be from high to
- low.
+ inclusive. If low > high, the sequence will be from high to low.
range examples
-foreach(range(0,9) as $number) {
- echo $number;
+foreach(range(0, 9) as $number) {
+ echo $number;
}
-foreach(range('a','z') as $letter) {
- echo $letter;
+foreach(range('a', 'z') as $letter) {
+ echo $letter;
}
-foreach(range('z','a') as $letter) {
- echo $letter;
+foreach(range('z', 'a') as $letter) {
+ echo $letter;
}
-
-
- Prior to version 4.0.7 the range() function only generated incrementing integer arrays.
- Support for character sequences and decrementing arrays was added in 4.0.7.
-
-
+
+
+ Prior to version 4.0.7 the range() function only generated
+ incrementing integer arrays. Support for character sequences
+ and decrementing arrays was added in 4.0.7.
+
+
See shuffle for another example of its use.
@@ -2935,7 +2948,8 @@
- The sizeof function is an alias for count.
+ The sizeof function is an alias for
+ count.
See also count.
@@ -2954,7 +2968,9 @@
void sortarray array
- int sort_flags
+ int
+ sort_flags
+
@@ -2962,7 +2978,7 @@
lowest to highest when this function has completed.
sort example
-
+
<?php
$fruits = array ("lemon", "orange", "banana", "apple");
@@ -2994,7 +3010,7 @@
The optional second parameter sort_flags
- may be used to modify the sorting behavior using theese valies:
+ may be used to modify the sorting behavior using these values:
Sorting type flags:
@@ -3015,7 +3031,8 @@
asort, ksort,
natsort, natcasesort,
rsort, usort,
- array_multisort, and uksort.
+ array_multisort, and
+ uksort.
@@ -3203,7 +3220,7 @@
function cmp ($a, $b) {
- return strcmp($a["fruit"],$b["fruit"]);
+ return strcmp($a["fruit"], $b["fruit"]);
}
$fruits[0]["fruit"] = "lemons";
@@ -3244,8 +3261,9 @@
- See also: uasort, uksort,
- sort, asort,
+ See also: uasort,
+ uksort, sort,
+ asort,
arsort,ksort,
natsort, and rsort.