PHP.nl

prev

prev

Rewind the internal array pointer

mixed **prev**  $array

Rewind the internal array pointer.

behaves just like ,

except it rewinds the internal array pointer one place instead of advancing it. prev``next

arrayThe input array.

Returns the array value in the previous place that's pointed to by the internal array pointer, or false if there are no more elements.

Voorbeeld: Example use of and friends

<?php
$transport = array('foot', 'bike', 'car', 'plane');
echo $mode = current($transport), PHP_EOL; // $mode = 'foot';
echo $mode = next($transport), PHP_EOL;    // $mode = 'bike';
echo $mode = next($transport), PHP_EOL;    // $mode = 'car';
echo $mode = prev($transport), PHP_EOL;    // $mode = 'bike';
echo $mode = end($transport), PHP_EOL;     // $mode = 'plane';
?>

Opmerking: > The beginning of an array is indistinguishable from a false element. To make the distinction, check that the of the element is not null. bool``key``prev

current``end``next``reset``each