Forum und email

reset

(PHP 4, PHP 5)

reset — 配列の内部ポインタを先頭の要素にセットする

説明

mixed reset ( array &$array )

reset() は、array の内部ポインタの先頭の要素に戻し、配列の最初の要素の値か、 配列が空の場合 FALSE を返します。

Example#1 reset() の例

<?php

$array 
= array('step one''step two''step three''step four');
  
// デフォルトでは、ポインタは先頭要素を指しています
echo current($array) . "<br />\n"// "step one"

// 次の2ステップをとばします
next($array);
next($array);
echo 
current($array) . "<br />\n"// "step three"
  
// ポインタをリセットし、再度ステップ1開始します
reset($array);
echo 
current($array) . "<br />\n"// "step one"

?>

current()each()end()next() および prev() も参照ください。