Definition:
An array in PHP has a current pointer which points to the first element by default, current() function is used to get the current elements of an array. It accepts an array and returns its current element.
Syntax:
current(array);
Note:
Parameter | Description |
---|---|
array | Required. Specifies the array to use |
Example1 : we can see below Output the value of the current element in an array
Output : web
The current()
function is commonly used along with the following functions:
prev()
– Moves the internal pointer of an array to the previous element, and returns its value.next()
– Moves the internal pointer of an array to the next element, and returns its value.end()
– Moves the internal pointer of an array to its last element, and returns its value.reset()
– Set the internal pointer of an array to its first element, and returns its value.key()
– Returns the key of the current element in an array.Example2 : Below example we can see the uses of current() functions
Output :
web
Designing
Designing
web
House
Designing
Designing
web
Designing