03-Apr-2023
.
Admin
Hi guys,
Today i will explained to the How To Get previous and next element in php array. This example is so easy to use in php. THis example to use current() and next() and prev() function to use.
Current(),next() and prev() function is provides to the php. The current() function is use array current value set and next() function is use next value set and prev() function is use previous value set in php array.
So let's start to the example and follow to the my all step.
Solution
echo current($language) . "<br>";
echo next($language) . "<br>";
echo prev($language);
Example :
This exampel to i will used to 4 value array create.
<?php
$language = array("laravel", "php", "java", "odo");
echo current($language) . "<br>";
echo next($language) . "<br>";
echo prev($language);
?>
Output :
laravel
php
laravel
So, finally we are done with our code we can get below output.
#PHP 8
#PHP