pointerNeither of these functions can move the pointer $arr = array ("Hello" = "one", "two", "three", and "one"); $a = current ($arr), returns the value corresponding to the present pointer, outputs one $b = key ($arr), returns the value of the index corresponding to the current pointer position, outputs the HelloNext (Array arr): Moves the pointer of the array down oneEnd (Array arr): Moves the pointer of the array to the lastprev (array arr): Moves the pointer of the array up
Gets the first (first element) of the arrayReset(PHP 4, PHP 5)Reset - Point The inner pointer of the array to the first cellDescription mixed Reset NBSP; ( NBSP; array NBSP; $array NBSP; ) Reset () the array internal pointer is inverted back to the first cell and returns the value of the first array cell.Parameters
array
The input array.
return valueReturns the value of the first cell of the array, or returns FALSE If the array is empty.ExampleExample #1 Re
The following describes how to use php to obtain the first value of an array. if you need it, refer to reset (PHP 3, PHP 4, PHP 5)
Reset -- point the internal pointer of the array to the first unit
DescriptionMixed reset (array array)Reset () returns the internal pointer of array to the first unit and the value of the first array unit. If the array is null, FALSE is returned.
Example 1. reset ()
The code is as follows:
$ Array = array ('stepone', 'step two', 'step three ', 'step four ');//
foreach traversalBasic syntax:foreach ( array name as key variable = = value variable ){Loop Body}foreach ( array name as value variable ){Loop Body}Array pointer-related functionsKey ( array name ): Gets the key of the current element of the arrayCurrent ( array name ): Gets the value of the present element of the arrayNext ( array name ): Moves the array pointer down oneReset ( array name ): resets the pointer to the array (the pointer to the array
value exists in the arrayarray_key_exists-checks whether the given key name or index exists in the arraynext-moves the inner pointer in the array forward onereset-the inner pointer of an array to the first cellrsort-reverse sequence of an arrayshuffle-Array is scrambledsort-sorting an array of arraysdirectory and file manipulation functionsI. Types of files1.filetype ()Get file type function, parameter is string (path + file name)The return value is
First of all, think about it? Is it possible to iterate through an array with a for?Can actually be but, not the real sense of traversal,for loop traversal, only suitable for index array, because we are to get the array subscript, and then use the subscript to access the elements of the array, but, logically, the subscript is part of the array, must be the first element to get the element subscript! We are accustomed to using foreach to iterate through an array, because the reason for the foreac
The following describes how to use php to obtain the first value of an array. if you need it, refer to reset (PHP 3, PHP 4, PHP 5)
Reset -- point the internal pointer of the array to the first unit
DescriptionMixed reset (array array)Reset () returns the internal pointer of array to the first unit and the value of the first array unit. If the array is null, FALSE is returned.
Example 1. reset () The code is as follows:
$ Array = array ('stepone', 'step two', 'step three ', 'step four ');// By
' where catid = 9 ";
$ Result = mysqli_query ($ db_conn, $ SQL) or die ("err in query 3:". $ SQL. mysqli_error ());;While (List ($ id, $ title, $ thumb, $ URL) = mysqli_fetch_row ($ result )){Echo """"}
List (), each (), reset (), current (), next (), end (), Prev ()
Each () returnsArrayThe key/value pair of the current pointer position in the array and move the array Pointer Forward. The key-value pair is returned as an array of four units, with the key name 0,1,KeyAndValue. Unit0And Ke
($ fruit_name = 'apple'){Echo key ($ array ).'';}Next ($ array);}?>
Bytes -------------------------------------------------------------------------------------------------------Reset
Reset -- point the internal pointer of the array to the first unit
Description mixedReset(Array array)
Reset ()Returns the internal pointer of array to the first unit and returns the value of the first array unit. If the array is emptyFALSE.
Example 1. res
Reset (PHP 3, PHP 4, PHP 5)
Reset--point the inner pointer of the array to the first cell
DescriptionMixed reset (array array)Reset () returns the internal pointer of the array back to the first cell and returns the value of the first array cell, FALSE if the array is empty.
Example 1. Reset () exampleCopy the Code code as follows:
$array = Array (' Stepone ', ' Step ', ' step three ', ' step Four ');By default, the pointer are on the first elementEcho current ($array). "\ n "; "Stepone"Skip
array forward oneReset ()-Points the inner pointer of the array to the first cell, restoringThe parameters here are all arrays to be manipulated.1 echo key ($arr);//returns the key under the current pointer of the current array; 2 echo "nbsp;nbsp;nbsp;nbsp;"; 3 echo current ($arr);//Returns values under the current pointer of an array; 4 echo "Operation Result:0 11 20 14 50 1Use combination to iterate through an array1 $arr =array ("One" =>1, "one",
Contact Us
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.