diff --git a/functions/array.xml b/functions/array.xml index c8e402bd05..06fa59b2af 100644 --- a/functions/array.xml +++ b/functions/array.xml @@ -1,5 +1,5 @@ - + Array Functions Arrays @@ -21,8 +21,8 @@ implemented and used in PHP. - See also is_array, explode, - implode, split + See also is_array, explode, + implode, split, and join. @@ -39,7 +39,7 @@ array array - mixed + mixed ... @@ -92,10 +92,10 @@ print_r($array); ]]> - will display : + will display : 1 [1] => 1 @@ -111,7 +111,7 @@ Array Note that index '3' is defined twice, and keep its final value of 13. Index 4 is defined after index 8, and next generated index (value 19) - is 9, since biggest index was 8. + is 9, since biggest index was 8. This example creates a 1-based array. @@ -124,10 +124,10 @@ print_r($firstquarter); ]]> - will display : + will display : 'January' [2] => 'February' @@ -140,7 +140,7 @@ Array See also array_pad, - list andrange. + list, and range. @@ -308,7 +308,7 @@ Array @@ -324,7 +324,7 @@ Array ]]> - + @@ -363,15 +363,15 @@ $result = array_diff ($array1, $array2); ]]> - + - This makes $result have + This makes $result have array ("blue");. Multiple occurences in $array1 are all treated the same way. - Two elements are considered equal if and only if + Two elements are considered equal if and only if (string) $elem1 === (string) $elem2. In words: when the string representation is the same. @@ -402,7 +402,7 @@ $result = array_diff ($array1, $array2); array array_filter array input - mixed + mixed callback @@ -411,7 +411,7 @@ $result = array_diff ($array1, $array2); array_filter returns an array containing all the elements of input filtered according a callback function. If the - input is an associative array + input is an associative array the keys are preserved. @@ -424,7 +424,7 @@ function odd($var) { } function even($var) { - return ($var % 2 == 0); + return ($var % 2 == 0); } $array1 = array ("a"=>1, "b"=>2, "c"=>3, "d"=>4, "e"=>5); @@ -459,10 +459,10 @@ Array - + ¬e.func-callback; - See also array_map, and + See also array_map and array_reduce. @@ -495,7 +495,7 @@ Array If a value has several occurences, the latest key will be - used as its values, and all others will be lost. + used as its values, and all others will be lost. array_flip returns &false; @@ -555,9 +555,9 @@ Array - array_fill fills an array with - num entries of the value of the - value parameter, keys starting at the + array_fill fills an array with + num entries of the value of the + value parameter, keys starting at the start_index parameter. @@ -584,7 +584,7 @@ Array ]]> - + @@ -623,7 +623,7 @@ $result = array_intersect ($array1, $array2); ]]> - This makes $result have + This makes $result have - + - Two elements are considered equal if and only if + Two elements are considered equal if and only if (string) $elem1 === (string) $elem2. In words: when the string representation is the same. @@ -885,7 +885,7 @@ print_r($d); The number 1 is called uno in Spanish [1] => The number 2 is called dos in Spanish @@ -895,7 +895,7 @@ Array ) // printout of $d -Array +Array ( [0] => Array ( @@ -1031,8 +1031,8 @@ Array If the input arrays have the same string keys, then the later - value for that key will overwrite the previous one. If, however, - the arrays have the same numeric key, the later value will not + value for that key will overwrite the previous one. If, however, + the arrays have the same numeric key, the later value will not overwrite the original value, but will be appended. @@ -1240,7 +1240,7 @@ array_multisort ($ar1, $ar2); @@ -1321,8 +1321,8 @@ $result = array_pad ($input, 2, "noop"); array_pop pops and returns the last value of the array, shortening the - array by one element. - If array is empty (or is not an array), + array by one element. + If array is empty (or is not an array), &null; will be returned. @@ -1346,7 +1346,7 @@ Array ) ]]> - and rasberry will be assigned to + and rasberry will be assigned to $fruit. @@ -1405,8 +1405,8 @@ array_push ($stack, "apple", "raspberry"); ]]> - This example would result in $stack having - the following elements: + This example would result in $stack having + the following elements: - + array_reverse @@ -1494,7 +1494,7 @@ print $input[$rand_keys[1]]."\n"; array array_reverse array array - bool + bool preserve_keys @@ -1518,7 +1518,7 @@ $result_keyed = array_reverse ($input, TRUE); This makes both $result and $result_keyed have the same elements, but - note the difference between the keys. The printout of + note the difference between the keys. The printout of $result and $result_keyed will be: @@ -1618,7 +1618,7 @@ $d = array_reduce($x, "rsum", 1); $d containing 1. - See also array_filter, and + See also array_filter and array_map. @@ -1667,14 +1667,14 @@ Array ) ]]> - and orange will be assigned to + and orange will be assigned to $fruit. See also array_unshift, - array_push and + array_push, and array_pop. @@ -1727,17 +1727,17 @@ Array See also array_splice. - + @@ -1809,7 +1809,7 @@ $output = array_slice ($input, 0, 3); // returns "a", "b" and "c" The following equivalences hold: @@ -1851,12 +1851,12 @@ array_splice ($input, -1, 1, array("black", "maroon")); - + array_sum - Calculate the sum of values in an array. + Calculate the sum of values in an array. @@ -1925,14 +1925,14 @@ sum(b) = 6.9 Note that keys are preserved. array_unique sorts - the values treated as string at first, then will keep the first key + the values treated as string at first, then will keep the first key encountered for every value, and ignore all following keys. It does not - mean that the key of the first related value from the unsorted + mean that the key of the first related value from the unsorted array will be kept. - Two elements are considered equal if and only if + Two elements are considered equal if and only if (string) $elem1 === (string) $elem2. In words: when the string representation is the same. @@ -2059,7 +2059,7 @@ Array See also array_shift, - array_push and + array_push, and array_pop. @@ -2148,18 +2148,18 @@ function array_values ($arr) { int array_walk array array string func - mixed + mixed userdata - Applies the user-defined function named by func + Applies the user-defined function named by func to each element of array. func will be passed array value as the first parameter and array key as the second parameter. If userdata is supplied, it will be passed as - the third parameter to the user function. func + the third parameter to the user function. func must be a user-defined function, and can't be a native PHP function. Thus, you can't use array_walk straight with str2lower, you must build a user-defined function @@ -2260,7 +2260,7 @@ c. fruit: apple void arsort array array - int + int sort_flags @@ -2301,12 +2301,12 @@ c = apple You may modify the behavior of the sort using the optional - parameter sort_flags, for details + parameter sort_flags, for details see sort. See also asort, rsort, - ksort and sort. + ksort, and sort. @@ -2322,7 +2322,7 @@ c = apple void asort array array - int + int sort_flags @@ -2363,12 +2363,12 @@ a = orange You may modify the behavior of the sort using the optional - parameter sort_flags, for details + parameter sort_flags, for details see sort. See also arsort, rsort, - ksort and sort. + ksort, and sort. @@ -2486,9 +2486,9 @@ Array - The sizeof function is an + The sizeof function is an alias for count. @@ -2540,27 +2540,27 @@ $result = count ($b); internal pointer points beyond the end of the elements list, current returns &false;. - + If the array contains empty elements (0 or "", the empty - string) then this function will return &false; - for these elements as well. This makes it impossible to - determine if you are really at the end of the list in such - an array using current. To properly + string) then this function will return &false; + for these elements as well. This makes it impossible to + determine if you are really at the end of the list in such + an array using current. To properly traverse an array that may contain empty elements, use the - each function. + each function. See also end, next, - prev andreset. + prev, and reset. - each + each Return the current key and value pair from an array and advance the array cursor @@ -2587,7 +2587,7 @@ $result = count ($b); If the internal pointer for the array points past the end of the - array contents, each returns + array contents, each returns &false;. @@ -2630,7 +2630,7 @@ $bar = each ($foo); each is typically used in conjunction with list to traverse an array; for instance, - $HTTP_POST_VARS: + $HTTP_POST_VARS: Traversing <varname>$HTTP_POST_VARS</varname> with @@ -2657,7 +2657,7 @@ while (list ($key, $val) = each ($HTTP_POST_VARS)) { <para> See also <function>key</function>, <function>list</function>, <function>current</function>, <function>reset</function>, - <function>next</function> and<function>prev</function>. + <function>next</function>, and <function>prev</function>. </para> </refsect1> </refentry> @@ -2683,8 +2683,8 @@ while (list ($key, $val) = each ($HTTP_POST_VARS)) { </para> <para> See also <function>current</function>, - <function>each</function>, - <function>next</function> and<function>reset</function>. + <function>each</function>, + <function>next</function>, and <function>reset</function>. </para> </refsect1> </refentry> @@ -2702,10 +2702,10 @@ while (list ($key, $val) = each ($HTTP_POST_VARS)) { <funcprototype> <funcdef>int <function>extract</function></funcdef> <paramdef>array <parameter>var_array</parameter></paramdef> - <paramdef>int + <paramdef>int <parameter><optional>extract_type</optional></parameter> </paramdef> - <paramdef>string + <paramdef>string <parameter><optional>prefix</optional></parameter> </paramdef> </funcprototype> @@ -2864,20 +2864,20 @@ blue, large, sphere, medium <funcdef>bool <function>in_array</function></funcdef> <paramdef>mixed <parameter>needle</parameter></paramdef> <paramdef>array <parameter>haystack</parameter></paramdef> - <paramdef>bool + <paramdef>bool <parameter><optional>strict</optional></parameter> </paramdef> </funcprototype> </funcsynopsis> <para> Searches <parameter>haystack</parameter> for - <parameter>needle</parameter> and returns &true; + <parameter>needle</parameter> and returns &true; if it is found in the array, &false; otherwise. </para> <para> If the third parameter <parameter>strict</parameter> is set to &true; then the <function>in_array</function> - will also check the <link linkend="language.types">types</link> of + will also check the <link linkend="language.types">types</link> of the <parameter>needle</parameter> in the <parameter>haystack</parameter>. </para> <note> @@ -2951,7 +2951,7 @@ if (in_array(1.13, $a, TRUE)) </refpurpose> </refnamediv> <refsect1> - <title>Description + Description mixed array_search @@ -3012,7 +3012,7 @@ if (in_array(1.13, $a, TRUE)) int krsort array array - int + int sort_flags @@ -3049,13 +3049,13 @@ a = orange You may modify the behavior of the sort using the optional - parameter sort_flags, for details + parameter sort_flags, for details see sort. See also asort, arsort, - ksort, sort, - natsort and rsort. + ksort, sort, + natsort, and rsort. @@ -3071,7 +3071,7 @@ a = orange int ksort array array - int + int sort_flags @@ -3104,16 +3104,16 @@ b = banana c = apple d = lemon ]]> - + You may modify the behavior of the sort using the optional - parameter sort_flags, for details + parameter sort_flags, for details see sort. - See also asort, arsort, - sort, natsort and + See also asort, arsort, + sort, natsort, and rsort. @@ -3204,7 +3204,7 @@ while (list ($id, $name, $salary) = mysql_fetch_row ($result)) { See also natcasesort, - strnatcmp and + strnatcmp, and strnatcasecmp. @@ -3287,7 +3287,7 @@ Array See also sort, natsort, - strnatcmp and + strnatcmp, and strnatcasecmp. @@ -3310,7 +3310,7 @@ Array Returns the array element in the next place that's pointed by the - internal array pointer, or &false; if + internal array pointer, or &false; if there are no more elements. @@ -3324,8 +3324,8 @@ Array If the array contains empty elements, or elements that have a key - value of 0 then this function will return &false; - for these elements as well. To properly traverse an array which + value of 0 then this function will return &false; + for these elements as well. To properly traverse an array which may contain empty elements or elements with key values of 0 see the each function. @@ -3334,7 +3334,7 @@ Array See also current, end, - prev andreset. + prev, and reset. @@ -3353,13 +3353,13 @@ Array - This is an alias + This is an alias for current. See also end, next, - prev and reset. + prev, and reset. @@ -3384,20 +3384,20 @@ Array If the array contains empty elements then this function will - return &false; for these elements as well. + return &false; for these elements as well. To properly traverse an array which may contain empty elements see the each function. - + prev behaves just like next, except it rewinds the internal array pointer one place instead of advancing it. See also current, end, - next andreset. + next, and reset. @@ -3510,7 +3510,7 @@ foreach(array_map('chr', range(ord('a'),ord('z'))) as $character) { void rsort array array - int + int sort_flags @@ -3549,13 +3549,13 @@ while (list ($key, $val) = each ($fruits)) { You may modify the behavior of the sort using the optional - parameter sort_flags, for details + parameter sort_flags, for details see sort. See also arsort, asort, ksort, - sort andusort. + sort, and usort. @@ -3594,7 +3594,7 @@ while (list (, $number) = each ($numbers)) { See also arsort, asort, ksort, rsort, - sort and usort. + sort, and usort. @@ -3613,7 +3613,7 @@ while (list (, $number) = each ($numbers)) { - The sizeof function is an + The sizeof function is an alias for count. @@ -3633,7 +3633,7 @@ while (list (, $number) = each ($numbers)) { void sort array array - int + int sort_flags @@ -3653,7 +3653,7 @@ reset ($fruits); while (list ($key, $val) = each ($fruits)) { echo "fruits[".$key."] = ".$val."\n"; } - + ?> ]]> @@ -3742,9 +3742,9 @@ fruits[3] = orange ¬e.func-callback; - See also usort, uksort, - sort, asort, - arsort, ksort + See also usort, uksort, + sort, asort, + arsort, ksort, and rsort. @@ -3776,7 +3776,7 @@ fruits[3] = orange <function>uksort</function> example $b) ? -1 : 1; } @@ -3806,10 +3806,10 @@ while (list ($key, $value) = each ($a)) { ¬e.func-callback; - See also usort, uasort, - sort, asort, + See also usort, uasort, + sort, asort, arsort, ksort, - natsort and rsort. + natsort, and rsort. @@ -3848,7 +3848,7 @@ while (list ($key, $value) = each ($a)) { <function>usort</function> example $b) ? -1 : 1; } @@ -3893,13 +3893,13 @@ while (list ($key, $value) = each ($a)) { uksort, sort, asort, arsort,ksort, - natsort andrsort. + natsort, and rsort.