<?php $transport = array('stopa', 'rower', 'samochód', 'samolot'); $tryb = current($transport); // $tryb = 'stopa'; $tryb = next($transport); // $tryb = 'rower'; $tryb = next($transport); // $tryb = 'samochód'; $tryb = prev($transport); // $tryb = 'rower'; $tryb = end($transport); // $tryb = 'samolot'; ?>
Sposób na ustalenie, jaki jest ostatni element badanej tablicy:
$array = array("one", "two", "three"); echo next($array); // "two" $last = array_pop(array_keys(array_flip($array))); echo $last; // "three" echo current($array); // "two"