Output the value of the current, next and previous element in the array in PHP

Description

The following code shows how to output the value of the current, next and previous element in the array.

Example


  /*  w ww .  j a va 2  s  . co  m*/
<?php
    $people = array("XML", "CSS", "Java", "Javascript");
    
    echo current($people) . "<br>";
    echo next($people) . "<br>";
    echo prev($people);
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Data Types »




Array
Array Associative
Array Util
ArrayObject
Data Types
Date
Date Format
DateTime
Number
String
String Escape
String Filter
String HTML
String Type
Timezone