In this simple article you will learn that how we can reset array pointer in PHP.
Arrays are just like the variable that store values but arrays can be used to store more than one value. Variable only store one value. There are three types of arrays
· Numeric arrays
· Associative array
· Multidimensional array
Pointers are used to point specific location. These are just like indexes that show the position of a variable.
Reset () function:
It is used to reset the pointer of an array. Reset () function basically reset the pointer to the first element of an array
Reset array pointer using reset() function in PHP:
To reset the pointer of an array we use the reset () function in php. It is the built-in function that set the pointer to the first element of an array. This function takes array as a parameter whose pointer we want to reset. In the given code we reset the array spice by using the reset () function and it returns the first element on the succeess or false on fail.
$spices = array("A", "B", "C", "D", "E");
$a_spice = each($spices);
Above is simple code to reset the array using reset () function in php.
This simple article tells that how we can reset the array using reset () function in php.
Reset array pointer in PHP