R4R Team working to provide free of cost for experienced and freshers

Tutorials | Examples|Interview Questions and Answers|Java Tutorials| C Tutorials | C++ Tutorials | Spring Tutorials| Hibernate Tutorials | JSP Tutorials | Servelets Tutorials| C# Tutorials | PHP Tutorials etc , Basics | Download Software | Data Types | Variables | Constant | Storage & Classes | Operators | Decisions Making | Loops | Functions| Numbers | Arrays | Pointers | String | Datastructure | Expressions | Preprocessor Statement | I/O | Exception Handling | OOPs Tutorial | Classes and object |C++ Inheritance Overloading | Polymorphism | Abstraction | Encapsulation | Interfaces | Multithreading etc

PHP Programing language

array_next() & array_prev() Function in PHP
Previous Home Next

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