PHP next() Function

PHP next Function


Defintion :

In PHP Array Functions The next() function moves the internal pointer of an array to the next element, and returns its value.

Syntax

The basic syntax of the next() function is given with:

   next(array);

Parameters :

The next() function accepts the following parameters.

Parameter Description
array Required. Specifies the array to work on.

The next() function is commonly used along with the following functions:

Related methods:

  • prev() - moves the internal pointer to, and outputs, the previous element in the array
  • current() - returns the value of the current element in an array
  • end() - moves the internal pointer to, and outputs, the last element in the array
  • reset() - moves the internal pointer to the first element of the array
  • each() - returns the current element key and value, and moves the internal pointer forward

Example : Below example Output the value of the current and the next element in the array: 

Output : 

Web
Designing