diff --git a/reference/array/functions/array-reverse.xml b/reference/array/functions/array-reverse.xml index f84507d7ac..d499316ab9 100644 --- a/reference/array/functions/array-reverse.xml +++ b/reference/array/functions/array-reverse.xml @@ -1,24 +1,76 @@ - - + array_reverse Return an array with elements in reverse order - - Description + + &reftitle.description; arrayarray_reverse arrayarray boolpreserve_keys - array_reverse takes input - array and returns a new array with the - order of the elements reversed, preserving the keys if - preserve_keys is &true;. + Takes an input array and returns a new array with + the order of the elements reversed. + + + &reftitle.parameters; + + + + array + + + The input array. + + + + + preserve_keys + + + If set to &true; keys are preserved. + + + + + + + + &reftitle.returnvalues; + + Returns the reversed array. + + + + &reftitle.changelog; + + + + + + &Version; + &Description; + + + + + 4.0.3 + + The preserve_keys parameter was added. + + + + + + + + + &reftitle.examples; <function>array_reverse</function> example @@ -66,13 +118,13 @@ Array - - - The second parameter was added in PHP 4.0.3. - - + + + &reftitle.seealso; - See also array_flip. + + array_flip + diff --git a/reference/array/functions/array-search.xml b/reference/array/functions/array-search.xml index 5de8d0f937..5cbfa2af67 100644 --- a/reference/array/functions/array-search.xml +++ b/reference/array/functions/array-search.xml @@ -1,13 +1,12 @@ - - + array_search Searches the array for a given value and returns the corresponding key if successful - - Description + + &reftitle.description; mixedarray_search mixedneedle @@ -15,35 +14,89 @@ boolstrict - Searches haystack for - needle and returns the key if it is found in - the array, &false; otherwise. + Searches haystack for needle. - - - If needle is a string, the comparison is done - in a case-sensitive manner. - - - - - Prior to PHP 4.2.0, array_search returns - &null; on failure instead of &false;. - - + + + &reftitle.parameters; - If the optional third parameter strict is set to - &true; then the array_search - will also check the types of the needle - in the haystack. + + + needle + + + The searched value. + + + + If needle is a string, the comparison is done + in a case-sensitive manner. + + + + + + haystack + + + The array. + + + + + strict + + + If the third parameter strict is set to &true; + then the array_search function will also check the + types of the + needle in the haystack. + + + + + + + + &reftitle.returnvalues; + + Returns the key for needle if it is found in the + array, &false; otherwise. - If needle is found in - haystack more than once, the first matching key - is returned. To return the keys for all matching values, use - array_keys with the optional + If needle is found in haystack + more than once, the first matching key is returned. To return the keys for + all matching values, use array_keys with the optional search_value parameter instead. + &return.falseproblem; + + + &reftitle.changelog; + + + + + + &Version; + &Description; + + + + + 4.2.0 + + Prior to PHP 4.2.0, array_search returns &null; + on failure instead of &false;. + + + + + + + + + &reftitle.examples; <function>array_search</function> example @@ -59,12 +112,16 @@ $key = array_search('red', $array); // $key = 1; - &return.falseproblem; + + + &reftitle.seealso; - See also array_keys, - array_values, - array_key_exists, and - in_array. + + array_keys + array_values + array_key_exists + in_array + diff --git a/reference/array/functions/array-shift.xml b/reference/array/functions/array-shift.xml index 18ef59c886..afbdcaafb0 100644 --- a/reference/array/functions/array-shift.xml +++ b/reference/array/functions/array-shift.xml @@ -1,13 +1,12 @@ - - + array_shift Shift an element off the beginning of array - - Description + + &reftitle.description; mixedarray_shift arrayarray @@ -17,15 +16,38 @@ array off and returns it, shortening the array by one element and moving everything down. All numerical array keys will be modified to start counting from zero - while literal keys won't be touched. If array is empty - (or is not an array), &null; will be returned. + while literal keys won't be touched. - &array.resetspointer; - - - <function>array_shift</function> example - + + + &reftitle.parameters; + + + + array + + + The input array. + + + + + + + + &reftitle.returnvalues; + + Returns the shifted value, or &null; if array is + empty or is not an array. + + + + &reftitle.examples; + + + <function>array_shift</function> example + ]]> - - - This would result in $stack having 3 elements left: - - + + &example.outputs; + raspberry ) ]]> - - - and orange will be assigned to - $fruit. - - + + + and orange will be assigned to + $fruit. + + + + + + &reftitle.seealso; - See also array_unshift, - array_push, and - array_pop. + + array_unshift + array_push + array_pop + diff --git a/reference/array/functions/array-slice.xml b/reference/array/functions/array-slice.xml index 46eafb0e10..83ef879693 100644 --- a/reference/array/functions/array-slice.xml +++ b/reference/array/functions/array-slice.xml @@ -1,13 +1,12 @@ - - + array_slice Extract a slice of the array - - Description + + &reftitle.description; arrayarray_slice arrayarray @@ -21,26 +20,88 @@ offset and length parameters. + + + &reftitle.parameters; - If offset is non-negative, the sequence will - start at that offset in the array. If - offset is negative, the sequence will - start that far from the end of the array. + + + array + + + The input array. + + + + + offset + + + If offset is non-negative, the sequence will + start at that offset in the array. If + offset is negative, the sequence will + start that far from the end of the array. + + + + + length + + + If length is given and is positive, then + the sequence will have that many elements in it. If + length is given and is negative then the + sequence will stop that many elements from the end of the + array. If it is omitted, then the sequence will have everything + from offset up until the end of the + array. + + + + + preserve_keys + + + Note that array_slice will reorder and reset the + array indices by default. You can change this behaviour by setting + preserve_keys to &true;. + + + + + + + &reftitle.returnvalues; - If length is given and is positive, then - the sequence will have that many elements in it. If - length is given and is negative then the - sequence will stop that many elements from the end of the - array. If it is omitted, then the sequence will have everything - from offset up until the end of the - array. + Returns the slice. + + + &reftitle.changelog; - Note that array_slice will reorder and reset the - array indices by default. Since PHP 5.0.2, you can change this - behaviour by setting preserve_keys to &true;. + + + + + &Version; + &Description; + + + + + 5.0.2 + + The optional preserve_keys parameter was added. + + + + + + + + &reftitle.examples; <function>array_slice</function> examples @@ -76,9 +137,14 @@ Array + + + &reftitle.seealso; - See also array_splice and - unset. + + array_splice + unset + diff --git a/reference/array/functions/array-udiff-assoc.xml b/reference/array/functions/array-udiff-assoc.xml index 9af4f9b226..2fcf9d1d69 100644 --- a/reference/array/functions/array-udiff-assoc.xml +++ b/reference/array/functions/array-udiff-assoc.xml @@ -1,13 +1,12 @@ - - + array_udiff_assoc Computes the difference of arrays with additional index check, compares data by a callback function - - Description + + &reftitle.description; arrayarray_udiff_assoc arrayarray1 @@ -15,6 +14,57 @@ array ... callbackdata_compare_func + + Computes the difference of arrays with additional index check, compares + data by a callback function. + + + + Please note that this function only checks one dimension of a n-dimensional + array. Of course you can check deeper dimensions by using, for example, + array_udiff_assoc($array1[0], $array2[0], "some_comparison_func");. + + + + + &reftitle.parameters; + + + + array1 + + + The first array. + + + + + array2 + + + The second array. + + + + + data_compare_func + + + The callback comparison function. + + + The user supplied callback function is used for comparison. + It must return an integer less than, equal to, or greater than zero if + the first argument is considered to be respectively less than, equal + to, or greater than the second. + + + + + + + + &reftitle.returnvalues; array_udiff_assoc returns an array containing all the values from array1 @@ -26,6 +76,9 @@ array_diff_assoc which uses internal function for comparison. + + + &reftitle.examples; <function>array_udiff_assoc</function> example @@ -83,32 +136,22 @@ Array pair is present in both arrays and thus it is not in the ouput from the function. - - For comparison is used the user supplied callback function. - It must return an integer less than, equal - to, or greater than zero if the first argument is considered to - be respectively less than, equal to, or greater than the - second. - - - - Please note that this function only checks one dimension of a n-dimensional - array. Of course you can check deeper dimensions by using, for example, - array_udiff_assoc($array1[0], $array2[0], "some_comparison_func");. - - + + + &reftitle.seealso; - See also - array_diff, - array_diff_assoc, - array_diff_uassoc, - array_udiff, - array_udiff_uassoc, - array_intersect, - array_intersect_assoc, - array_uintersect, - array_uintersect_assoc and - array_uintersect_uassoc. + + array_diff + array_diff_assoc + array_diff_uassoc + array_udiff + array_udiff_uassoc + array_intersect + array_intersect_assoc + array_uintersect + array_uintersect_assoc + array_uintersect_uassoc + diff --git a/reference/array/functions/array-uintersect-assoc.xml b/reference/array/functions/array-uintersect-assoc.xml index 9653f74c1a..30123681f4 100644 --- a/reference/array/functions/array-uintersect-assoc.xml +++ b/reference/array/functions/array-uintersect-assoc.xml @@ -1,12 +1,12 @@ - + array_uintersect_assoc Computes the intersection of arrays with additional index check, compares data by a callback function - - Description + + &reftitle.description; arrayarray_uintersect_assoc arrayarray1 @@ -15,12 +15,59 @@ callbackdata_compare_func - array_uintersect_assoc returns an array - containing all the values of array1 - that are present in all the arguments. Note that the keys are used in - the comparison unlike in array_uintersect. + Computes the intersection of arrays with additional index check, compares + data by a callback function. + + + Note that the keys are used in the comparison unlike in + array_uintersect. The data is compared by using a callback function. + + + &reftitle.parameters; + + + + array1 + + + The first array. + + + + + array2 + + + The second array. + + + + + data_compare_func + + + For comparison is used the user supplied callback function. + It must return an integer less than, equal + to, or greater than zero if the first argument is considered to + be respectively less than, equal to, or greater than the + second. + + + + + + + + &reftitle.returnvalues; + + Returns an array containing all the values of + array1 that are present in all the arguments. + + + + &reftitle.examples; <function>array_uintersect_assoc</function> example @@ -45,18 +92,16 @@ Array + + + &reftitle.seealso; - For comparison is used the user supplied callback function. - It must return an integer less than, equal - to, or greater than zero if the first argument is considered to - be respectively less than, equal to, or greater than the - second. - - - See also array_uintersect, - array_intersect_assoc, - array_intersect_uassoc and - array_uintersect_uassoc. + + array_uintersect + array_intersect_assoc + array_intersect_uassoc + array_uintersect_uassoc + diff --git a/reference/array/functions/array-unique.xml b/reference/array/functions/array-unique.xml index fbac23d4db..d4929b4aae 100644 --- a/reference/array/functions/array-unique.xml +++ b/reference/array/functions/array-unique.xml @@ -1,20 +1,18 @@ - - + array_unique Removes duplicate values from an array - - Description + + &reftitle.description; arrayarray_unique arrayarray - array_unique takes input - array and returns a new array + Takes an input array and returns a new array without duplicate values. @@ -34,6 +32,30 @@ The first element will be used. + + + &reftitle.parameters; + + + + array + + + The input array. + + + + + + + + &reftitle.returnvalues; + + Returns the filtered array. + + + + &reftitle.examples; <function>array_unique</function> example diff --git a/reference/array/functions/asort.xml b/reference/array/functions/asort.xml index f57d13ac61..f423cc051c 100644 --- a/reference/array/functions/asort.xml +++ b/reference/array/functions/asort.xml @@ -1,13 +1,12 @@ - - + asort Sort an array and maintain index association - - Description + + &reftitle.description; boolasort arrayarray @@ -19,12 +18,44 @@ with. This is used mainly when sorting associative arrays where the actual element order is significant. + + + &reftitle.parameters; + + + + array + + + The input array. + + + + + sort_flags + + + You may modify the behavior of the sort using the optional + parameter sort_flags, for details + see sort. + + + + + + + + &reftitle.returnvalues; &return.success; - - <function>asort</function> example - + + + &reftitle.examples; + + + <function>asort</function> example + "lemon", "a" => "orange", "b" => "banana", "c" => "apple"); @@ -34,29 +65,32 @@ foreach ($fruits as $key => $val) { } ?> ]]> - - &example.outputs; - + + &example.outputs; + - - - - The fruits have been sorted in alphabetical order, and the index - associated with each element has been maintained. + + + The fruits have been sorted in alphabetical order, and the index + associated with each element has been maintained. + + + + + &reftitle.seealso; - You may modify the behavior of the sort using the optional - parameter sort_flags, for details - see sort. - - - See also arsort, rsort, - ksort, and sort. + + arsort + sort + ksort + rsort + diff --git a/reference/array/functions/count.xml b/reference/array/functions/count.xml index 6610604862..ba0b7020ee 100644 --- a/reference/array/functions/count.xml +++ b/reference/array/functions/count.xml @@ -1,22 +1,19 @@ - - + count Count elements in an array, or properties in an object - - Description + + &reftitle.description; intcount mixedvar intmode - Returns the number of elements in var, - which is typically an array, since anything else - will have one element. + Counts elements in an array, or properties in an object. For objects, if you have @@ -26,6 +23,47 @@ count, which returns the return value for the count function. + + Please see the Array + section of the manual for a detailed explanation of how arrays + are implemented and used in PHP. + + + + &reftitle.parameters; + + + + var + + + The array. + + + + + mode + + + If the optional mode parameter is set to + COUNT_RECURSIVE (or 1), count + will recursively count the array. This is particularly useful for + counting all the elements of a multidimensional array. The default + value for mode is 0. + count does not detect infinite recursion. + + + + + + + + &reftitle.returnvalues; + + Returns the number of elements in var, which is + typically an array, since anything else will have one + element. + If var is not an array or an object with implemented Countable interface, @@ -33,33 +71,39 @@ There is one exception, if var is &null;, 0 will be returned. - - - The optional mode parameter is available as of - PHP 4.2.0. - - - - If the optional mode parameter is set to - COUNT_RECURSIVE (or 1), count - will recursively count the array. This is particularly useful for - counting all the elements of a multidimensional array. The default - value for mode is 0. - count does not detect infinite recursion. - - count 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 - isset to test if a variable is set. + count 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 isset to test if a variable is set. + + + &reftitle.changelog; - Please see the Array - section of the manual for a detailed explanation of how arrays - are implemented and used in PHP. + + + + + &Version; + &Description; + + + + + 4.2.0 + + The optional mode parameter was added. + + + + + + + + &reftitle.examples; <function>count</function> example @@ -90,9 +134,7 @@ $result = count(false); - - Recursive <function>count</function> example (PHP >= 4.2.0) - + Recursive <function>count</function> example + + + &reftitle.seealso; - See also is_array, - isset, and - strlen. + + is_array + isset + strlen + diff --git a/reference/array/functions/current.xml b/reference/array/functions/current.xml index 25f667ef3e..be3fb7f977 100644 --- a/reference/array/functions/current.xml +++ b/reference/array/functions/current.xml @@ -1,13 +1,12 @@ - - + current Return the current element in an array - - Description + + &reftitle.description; mixedcurrent arrayarray @@ -17,6 +16,24 @@ which is initialized to the first element inserted into the array. + + + &reftitle.parameters; + + + + array + + + The array. + + + + + + + + &reftitle.returnvalues; The current function simply returns the value of the array element that's currently being pointed to by the @@ -24,17 +41,10 @@ internal pointer points beyond the end of the elements list, current returns &false;. - &return.falseproblem; - - - - You won't be able to distinguish the end of an array from a - boolean &false; element. To properly traverse an array - which may contain &false; elements, see the each - function. - - + + + &reftitle.examples; Example use of <function>current</function> and friends @@ -53,10 +63,29 @@ $mode = current($transport); // $mode = 'plane'; + + + &reftitle.notes; + + + You won't be able to distinguish the end of an array from a + boolean &false; element. To properly traverse an array + which may contain &false; elements, see the each + function. + + + + + &reftitle.seealso; - See also end, key, - next, prev, - reset, and each. + + end + key + each + prev + reset + next + diff --git a/reference/array/functions/each.xml b/reference/array/functions/each.xml index 22b6c7d348..5eea15f184 100644 --- a/reference/array/functions/each.xml +++ b/reference/array/functions/each.xml @@ -1,33 +1,62 @@ - - + each Return the current key and value pair from an array and advance the array cursor - - Description + + &reftitle.description; arrayeach arrayarray + + Return the current key and value pair from an array and advance the array + cursor. + + + After each has executed, the array cursor + will be left on the next element of the array, or past the last + element if it hits the end of the array. You have to use + reset if you want to traverse the array + again using each. + + + + &reftitle.parameters; + + + + array + + + The input array. + + + + + + + + &reftitle.returnvalues; Returns the current key and value pair from the array - array and advances the array cursor. This - pair is returned in a four-element array, with the keys - 0, 1, - key, and - value. Elements 0 and - key contain the key name of the array - element, and 1 and - value contain the data. + array. This pair is returned in a four-element + array, with the keys 0, 1, + key, and value. Elements + 0 and key contain the key name of + the array element, and 1 and value + contain the data. If the internal pointer for the array points past the end of the array contents, each returns &false;. + + + &reftitle.examples; <function>each</function> examples @@ -113,13 +142,6 @@ c => cranberry - - After each has executed, the array cursor - will be left on the next element of the array, or past the last - element if it hits the end of the array. You have to use - reset if you want to traverse the array - again using each. - Because assigning an array to another variable resets the original @@ -128,11 +150,19 @@ c => cranberry loop. + + + &reftitle.seealso; - See also key, list, - current, reset, - next, prev, and - foreach. + + key + list + current + reset + next + prev + foreach + diff --git a/reference/array/functions/end.xml b/reference/array/functions/end.xml index 0d347ed8e5..f2c821129c 100644 --- a/reference/array/functions/end.xml +++ b/reference/array/functions/end.xml @@ -1,6 +1,5 @@ - - + end diff --git a/reference/array/functions/in-array.xml b/reference/array/functions/in-array.xml index 7d2b820383..70a9b48803 100644 --- a/reference/array/functions/in-array.xml +++ b/reference/array/functions/in-array.xml @@ -1,13 +1,12 @@ - - + in_array Checks if a value exists in an array - - Description + + &reftitle.description; boolin_array mixedneedle @@ -15,28 +14,81 @@ boolstrict - Searches haystack for - needle and returns &true; - if it is found in the array, &false; otherwise. + Searches haystack for needle. + + + &reftitle.parameters; - If the third parameter strict is set to - &true; then the in_array function - will also check the types of - the needle in the haystack. + + + needle + + + The searched value. + + + + If needle is a string, the comparison is done + in a case-sensitive manner. + + + + + + haystack + + + The array. + + + + + strict + + + If the third parameter strict is set to &true; + then the in_array function will also check the + types of the + needle in the haystack. + + + + - - - If needle is a string, the comparison is done in - a case-sensitive manner. - - - - - In PHP versions before 4.2.0 needle was not - allowed to be an array. - - + + + &reftitle.returnvalues; + + Returns &true; if needle is found in the array, + &false; otherwise. + + + + &reftitle.changelog; + + + + + + &Version; + &Description; + + + + + 4.2.0 + + needle may now be an array. + + + + + + + + + &reftitle.examples; <function>in_array</function> example @@ -121,10 +173,15 @@ if (in_array('o', $a)) { + + + &reftitle.seealso; - See also array_search, - array_key_exists, and - isset. + + array_search + isset + array_key_exists + diff --git a/reference/array/functions/ksort.xml b/reference/array/functions/ksort.xml index d6e0d418d4..28e3d5d493 100644 --- a/reference/array/functions/ksort.xml +++ b/reference/array/functions/ksort.xml @@ -1,25 +1,78 @@ - - + ksort Sort an array by key - - Description + + &reftitle.description; boolksort arrayarray intsort_flags - Sorts an array by key, maintaining key to data correlations. This - is useful mainly for associative arrays. + Sorts an array by key, maintaining key to data correlations. This is + useful mainly for associative arrays. + + + &reftitle.parameters; + + + + array + + + The input array. + + + + + sort_flags + + + You may modify the behavior of the sort using the optional + parameter sort_flags, for details + see sort. + + + + + + + + &reftitle.returnvalues; &return.success; + + + &reftitle.changelog; + + + + + + &Version; + &Description; + + + + + 4.0.0 + + The optional sort_flags parameter was added. + + + + + + + + + &reftitle.examples; <function>ksort</function> example @@ -45,22 +98,20 @@ d = lemon + + + &reftitle.seealso; - You may modify the behavior of the sort using the optional - parameter sort_flags, for details - see sort. + + asort + arsort + krsort + uksort + sort + natsort + rsort + - - See also asort, arsort, - krsort, uksort, - sort, natsort, and - rsort. - - - - The second parameter was added in PHP 4. - - diff --git a/reference/array/functions/list.xml b/reference/array/functions/list.xml index 5b631c76ca..e2b573eafd 100644 --- a/reference/array/functions/list.xml +++ b/reference/array/functions/list.xml @@ -1,13 +1,12 @@ - - + list Assign variables as if they were an array - - Description + + &reftitle.description; voidlist mixedvarname @@ -18,12 +17,30 @@ but a language construct. list is used to assign a list of variables in one operation. - - - list only works on numerical arrays and assumes - the numerical indices start at 0. - - + + + &reftitle.parameters; + + + + varname + + + A variable. + + + + + + + + &reftitle.returnvalues; + + &return.void; + + + + &reftitle.examples; <function>list</function> examples @@ -81,16 +98,6 @@ while (list($id, $name, $salary) = mysql_fetch_row($result)) { - - - list assigns the values starting with the right-most - parameter. If you are using plain variables, you don't have to worry - about this. But if you are using arrays with indices you usually expect - the order of the indices in the array the same you wrote in the - list from left to right; which it isn't. It's - assigned in the reverse order. - - Using <function>list</function> with array indices @@ -125,9 +132,34 @@ array(3) { + + + &reftitle.notes; + + + list assigns the values starting with the right-most + parameter. If you are using plain variables, you don't have to worry + about this. But if you are using arrays with indices you usually expect + the order of the indices in the array the same you wrote in the + list from left to right; which it isn't. It's + assigned in the reverse order. + + + + + list only works on numerical arrays and assumes + the numerical indices start at 0. + + + + + &reftitle.seealso; - See also each, array - and extract. + + each + array + extract + diff --git a/reference/array/functions/natcasesort.xml b/reference/array/functions/natcasesort.xml index 4de134365f..f001a249fc 100644 --- a/reference/array/functions/natcasesort.xml +++ b/reference/array/functions/natcasesort.xml @@ -1,29 +1,49 @@ - - + natcasesort Sort an array using a case insensitive "natural order" algorithm - - Description + + &reftitle.description; boolnatcasesort arrayarray + + natcasesort is a case insensitive version of + natsort. + This function implements a sort algorithm that orders alphanumeric strings in the way a human being would while maintaining key/value associations. This is described as a "natural ordering". + + + &reftitle.parameters; + + + + array + + + The input array. + + + + + + + + &reftitle.returnvalues; &return.success; - - natcasesort is a case insensitive version of - natsort. - + + + &reftitle.examples; <function>natcasesort</function> example @@ -75,11 +95,16 @@ Array + + + &reftitle.seealso; - See also sort, - natsort, - strnatcmp, and - strnatcasecmp. + + sort + natsort + strnatcmp + strnatcasecmp + diff --git a/reference/array/functions/natsort.xml b/reference/array/functions/natsort.xml index c0b08dfe1f..a2c0ec65d8 100644 --- a/reference/array/functions/natsort.xml +++ b/reference/array/functions/natsort.xml @@ -1,28 +1,47 @@ - - + natsort Sort an array using a "natural order" algorithm - - Description + + &reftitle.description; boolnatsort arrayarray - This function implements a sort algorithm that orders - alphanumeric strings in the way a human being would while maintaining - key/value associations. This is described as a "natural ordering". An - example of the difference between this algorithm and the regular computer - string sorting algorithms (used in sort) can be seen - below: + This function implements a sort algorithm that orders alphanumeric strings + in the way a human being would while maintaining key/value associations. + This is described as a "natural ordering". An example of the difference + between this algorithm and the regular computer string sorting algorithms + (used in sort) can be seen in the example below. + + + &reftitle.parameters; + + + + array + + + The input array. + + + + + + + + &reftitle.returnvalues; &return.success; + + + &reftitle.examples; <function>natsort</function> example @@ -70,10 +89,15 @@ Array + + + &reftitle.seealso; - See also natcasesort, - strnatcmp, and - strnatcasecmp. + + natcasesort + strnatcmp + strnatcasecmp + diff --git a/reference/array/functions/next.xml b/reference/array/functions/next.xml index 8db054c2e8..ddcd18d3ad 100644 --- a/reference/array/functions/next.xml +++ b/reference/array/functions/next.xml @@ -1,33 +1,31 @@ - - + next Advance the internal array pointer of an array - - Description + + &reftitle.description; mixednext arrayarray - - Returns the array value in the next place that's pointed to by the - internal array pointer, or &false; if there are no more elements. - next behaves like current, with one difference. It advances the internal array pointer one place forward before returning the element value. That means it returns the next array value and - advances the internal array pointer by one. If advancing the - internal array pointer results in going beyond the end of the - element list, next returns &false;. + advances the internal array pointer by one. + + + + &reftitle.returnvalues; + + Returns the array value in the next place that's pointed to by the + internal array pointer, or &false; if there are no more elements. - &return.falseproblem; - You won't be able to distinguish the end of an array from a @@ -36,6 +34,9 @@ function. + + + &reftitle.examples; Example use of <function>next</function> and friends @@ -53,11 +54,17 @@ $mode = end($transport); // $mode = 'plane'; + + + &reftitle.seealso; - See also - current, end, - prev, reset, - and each. + + current + end + prev + reset + each + diff --git a/reference/array/functions/range.xml b/reference/array/functions/range.xml index 2bbe394f9f..b3f7015241 100644 --- a/reference/array/functions/range.xml +++ b/reference/array/functions/range.xml @@ -1,13 +1,12 @@ - - + range Create an array containing a range of elements - - Description + + &reftitle.description; arrayrange mixedlow @@ -15,22 +14,95 @@ numberstep - range returns an array of elements from - low to high, - inclusive. If low > high, the sequence will be from high to low. + Create an array containing a range of elements. - - New parameter - - The optional step parameter was added in 5.0.0. - - + + + &reftitle.parameters; - If a step value is given, it will be used as the - increment between elements in the sequence. step - should be given as a positive number. If not specified, - step will default to 1. + + + low + + + Low value. + + + + + high + + + High value. + + + + + step + + + If a step value is given, it will be used as the + increment between elements in the sequence. step + should be given as a positive number. If not specified, + step will default to 1. + + + + + + + &reftitle.returnvalues; + + Returns an array of elements from low to + high, inclusive. If low > high, the sequence will + be from high to low. + + + + &reftitle.changelog; + + + + + + &Version; + &Description; + + + + + 5.0.0 + + The optional step parameter was added. + + + + 4.1.0 to 4.3.2 + + In PHP versions 4.1.0 through 4.3.2, range sees + numeric strings as strings and not integers. Instead, they will be + used for character sequences. For example, "4242" + is treated as "4". + + + + 4.1.0 + + Prior to PHP 4.1.0, range only generated + incrementing integer arrays. Support for character sequences and + decrementing arrays was added in 4.1.0. Character sequence values + are limited to a length of one. If a length greater than one is + entered, only the first character is used. + + + + + + + + + &reftitle.examples; <function>range</function> examples @@ -62,27 +134,15 @@ foreach (range('c', 'a') as $letter) { - - - Prior to PHP 4.1.0, range only generated - incrementing integer arrays. Support for character sequences and - decrementing arrays was added in 4.1.0. Character sequence values - are limited to a length of one. If a length greater than one is - entered, only the first character is used. - - - - - In PHP versions 4.1.0 through 4.3.2, range sees - numeric strings as strings and not integers. Instead, they will be - used for character sequences. For example, "4242" - is treated as "4". - - + + + &reftitle.seealso; - See also shuffle, - array_fill, and - foreach. + + shuffle + array_fill + foreach + diff --git a/reference/array/functions/sort.xml b/reference/array/functions/sort.xml index 84e9538820..8d1e776cea 100644 --- a/reference/array/functions/sort.xml +++ b/reference/array/functions/sort.xml @@ -1,13 +1,12 @@ - - + sort Sort an array - - Description + + &reftitle.description; boolsort arrayarray @@ -17,10 +16,85 @@ This function sorts an array. Elements will be arranged from lowest to highest when this function has completed. - ¬e.no-key-association; + + + &reftitle.parameters; + + + + array + + + The input array. + + + + + sort_flags + + + The optional second parameter sort_flags + may be used to modify the sorting behavior using these values: + + + Sorting type flags: + + + SORT_REGULAR - compare items normally + (don't change types) + + + SORT_NUMERIC - compare items numerically + + + SORT_STRING - compare items as strings + + + SORT_LOCALE_STRING - compare items as + strings, based on the current locale. Added in PHP 4.4.0 and 5.0.2. + Before PHP 6, it uses the system locale, which can be changed using + setlocale. Since PHP 6, you must use the + i18n_loc_set_default function. + + + + + + + + + + + &reftitle.returnvalues; &return.success; + + + &reftitle.changelog; + + + + + + &Version; + &Description; + + + + + 4.0.0 + + The sort_flags parameter was added. + + + + + + + + + &reftitle.examples; <function>sort</function> example @@ -51,52 +125,32 @@ fruits[3] = orange The fruits have been sorted in alphabetical order. - - The optional second parameter sort_flags - may be used to modify the sorting behavior using these values: - - - Sorting type flags: - - - SORT_REGULAR - compare items normally - (don't change types) - - - SORT_NUMERIC - compare items numerically - - - SORT_STRING - compare items as strings - - - SORT_LOCALE_STRING - compare items as - strings, based on the current locale. Added in PHP 4.4.0 and 5.0.2. - Before PHP 6, it uses the system locale, which can be changed using - setlocale. Since PHP 6, you must use the - i18n_loc_set_default function. - - - - - - - The second parameter was added in PHP 4. - - + + + &reftitle.notes; + ¬e.no-key-association; Be careful when sorting arrays with mixed types values because sort can produce unpredictable results. + + + &reftitle.seealso; - See also arsort, - asort, ksort, - krsort, - natsort, natcasesort, - rsort, usort, - array_multisort, and - uksort. + + arsort + asort + ksort + rsort + usort + uksort + array_multisort + krsort + natsort + natcasesort + diff --git a/reference/array/functions/uksort.xml b/reference/array/functions/uksort.xml index ed14d09b29..abb53984d7 100644 --- a/reference/array/functions/uksort.xml +++ b/reference/array/functions/uksort.xml @@ -1,13 +1,12 @@ - - + uksort Sort an array by keys using a user-defined comparison function - - Description + + &reftitle.description; booluksort arrayarray @@ -19,17 +18,46 @@ needs to be sorted by some non-trivial criteria, you should use this function. + + + &reftitle.parameters; - Function cmp_function should accept two - parameters which will be filled by pairs of array keys. - The comparison function must return an integer less than, equal - to, or greater than zero if the first argument is considered to - be respectively less than, equal to, or greater than the - second. + + + array + + + The input array. + + + + + cmp_function + + + The callback comparison function. + + + Function cmp_function should accept two + parameters which will be filled by pairs of array keys. + The comparison function must return an integer less than, equal + to, or greater than zero if the first argument is considered to + be respectively less than, equal to, or greater than the + second. + + + + + + + &reftitle.returnvalues; &return.success; + + + &reftitle.examples; <function>uksort</function> example @@ -64,11 +92,20 @@ John: 1 + + + &reftitle.seealso; - See also usort, uasort, - sort, asort, - arsort, ksort, - natsort, and rsort. + + usort + uasort + sort + asort + arsort + ksort + natsort + rsort + diff --git a/reference/array/functions/usort.xml b/reference/array/functions/usort.xml index bb7625207d..366d3b34ea 100644 --- a/reference/array/functions/usort.xml +++ b/reference/array/functions/usort.xml @@ -1,44 +1,86 @@ - - + usort Sort an array by values using a user-defined comparison function - - Description + + &reftitle.description; boolusort arrayarray callbackcmp_function - This function will sort an array by its values using a - user-supplied comparison function. If the array you wish to sort - needs to be sorted by some non-trivial criteria, you should use - this function. - - - The comparison function must return an integer less than, equal - to, or greater than zero if the first argument is considered to - be respectively less than, equal to, or greater than the - second. - - - - - If two members compare as equal, their order in the sorted array is undefined. - Up to PHP 4.0.6 the user defined functions would keep the original order for - those elements, but with the new sort algorithm introduced with 4.1.0 this - is no longer the case as there is no solution to do so in an efficient way. - - + This function will sort an array by its values using a user-supplied + comparison function. If the array you wish to sort needs to be sorted by + some non-trivial criteria, you should use this function. + + + If two members compare as equal, their order in the sorted array is undefined. + + ¬e.no-key-association; + + + &reftitle.parameters; + + + + array + + + The input array. + + + + + cmp_function + + + The comparison function must return an integer less than, equal to, or + greater than zero if the first argument is considered to be + respectively less than, equal to, or greater than the second. + + + + + + + + &reftitle.returnvalues; &return.success; + + + &reftitle.changelog; + + + + + + &Version; + &Description; + + + + + 4.1.0 + + A new sort algorithm was introduced. The cmp_function + doesn't keep the original order for elements comparing as equal. + + + + + + + + + &reftitle.examples; <function>usort</function> example @@ -120,7 +162,6 @@ $fruits[2]: lemons - @@ -171,13 +212,20 @@ d </screen> </example> </para> - + </refsect1> + <refsect1 role="seealso"> + &reftitle.seealso; <para> - See also <function>uasort</function>, - <function>uksort</function>, <function>sort</function>, - <function>asort</function>, - <function>arsort</function>,<function>ksort</function>, - <function>natsort</function>, and <function>rsort</function>. + <simplelist> + <member><function>uasort</function></member> + <member><function>uksort</function></member> + <member><function>sort</function></member> + <member><function>asort</function></member> + <member><function>arsort</function></member> + <member><function>ksort</function></member> + <member><function>natsort</function></member> + <member><function>rsort</function></member> + </simplelist> </para> </refsect1> </refentry>