SYNCERのロゴ
アイキャッチ画像

reset - ポインタを先頭の要素にセットする

ポインタを先頭の要素にセットして、その値を返します。

構文

mixed reset ( array &$array )

パラメータ

&$array

対象の配列。

返り値

mixed

先頭の要素の値。存在しない場合はfalseを返す。

サンプルコード

<?php
	$array = [ "a", "b", "c", "d", "e" ] ;

	$response = reset( $array ) ;

デモ

next()やprev()でポインタの位置を変更した後、リセットする例です。

<?php
/*** このコードは編集できます。 ***/

	$array = [ "a", "b", "c", "d", "e" ] ;

	next( $array ) ;
	next( $array ) ;
	prev( $array ) ;
	next( $array ) ;

	$response = reset( $array ) ;

	var_dump( $response ) ;
  • Twitterでシェア
  • Facebookでシェア
  • Google+でシェア
  • はてなブックマークでシェア
  • pocketに保存
  • LINEでシェア
更新履歴
2017年6月26日 (月)
コンテンツを公開しました。