PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

range> <pos
Last updated: Fri, 18 Jul 2008

view this page in

prev

(PHP 4, PHP 5)

prev — Decrementa il puntatore interno dell'array

Descrizione

mixed prev ( array $array )

Restituisce l'elemento dell'array che sta nella posizione precedente a quella attuale indicata dal puntatore interno, oppure FALSE se non ci sono altri elementi.

Avviso

Se l'array contiene degli elementi vuoti la funzione restituirà FALSE per questi valori. Per esplorare correttamente un array che può contenere elementi vuoti vedere la funzione each().

prev() si comporta come next(), tranne per il fatto di decrementare il puntatore interno di una posizione, invece che incrementarlo.

Example #1 Esempio di prev() e funzioni relative

<?php
$trasporti 
= array('piedi''bicicletta''automobile''aereo');
$mode current($trasporti); // $mode = 'piedi';
$mode next($trasporti);    // $mode = 'bicicletta';
$mode next($trasporti);    // $mode = 'automobile';
$mode prev($trasporti);    // $mode = 'piedi';
$mode end($trasporti);     // $mode = 'aereo';
?>

Vedere anche current(), end(), next() e reset().



add a note add a note User Contributed Notes
prev
xmlich02 at stud dot fit dot vutbr dot cz
29-Sep-2007 12:19
// example of backward iteration

$ar = array ( 'a', 'b', 'c', 'd', 'e', 'f') ;

print_r($ar);

end($ar);
while($val = current($ar)) {
  echo $val.' ';
  prev($ar);
}

range> <pos
Last updated: Fri, 18 Jul 2008
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites