PHP Programing language

adplus-dvertising
array_next() & array_prev() Function in PHP
Previous Home Next
adplus-dvertising

array_next()

The next() function moves the internal pointer to, and outputs, the next element in the array.

Syntax:
next(array)

In above syntax, "array" specifies the array to use.

Example:

<?php
$vehicle = array("Car", "Scooter", "Motorcycle", "Truck");
echo current($vehicle)."<br>";
echo next($vehicle);
?>

Output:

Car
Scooter

array_prev()

The prev() function moves the internal pointer to, and outputs, the previous element in the array.

Syntax:
prev(array)

In above syntax, "array" specifies the array to use.

Example:

<?php
$vehicle = array("Car", "Scooter", "Motorcycle", "Truck");
echo current($vehicle)."<br>";
echo next($vehicle). "<br>";
echo prev($vehicle);
?>

Output:

Car
Scooter
Car

Previous Home Next