Changes

Jump to: navigation, search

PHP Arrays

533 bytes added, 18:03, 1 June 2007
Using Array Pointers
Each function takes the name of the array in which the pointer adjustment is to take place as an argument:
 
<pre>
<?php
$colorArray = array("Red", "Yellow", "Green", "Blue", "Indigo");
 
echo 'The last element is ' . end($colorArray) . '<br>';
echo 'The previous element is ' . prev($colorArray) . '<br>';
echo 'The first element is ' . reset($colorArray) . '<br>';
echo 'The next element is ' . next($colorArray) . '<br>';
?>
</pre>
 
The above example will display the following output:
 
<pre>
The last element is Indigo
The previous element is Blue
The first element is Red
The next element is Yellow
</pre>

Navigation menu