최신 웹 개발 튜토리얼
 

PHP reset() Function

<PHP 배열 문헌

어레이 출력에서의 전류 및 다음 요소의 값을, 그 배열의 첫 번째 요소 배열의 내부 포인터를 초기화 :

<?php
$people = array("Peter", "Joe" , "Glenn" , "Cleveland");

echo current($people) . "<br>";
echo next($people) . "<br>";

echo reset($people);
?>
»실행 예

정의 및 사용

reset() 함수는 상기 어레이의 첫 번째 요소 내부 포인터를 이동한다.

관련 방법 :

  • current() - 배열의 현재 원소의 값을 반환
  • end() - 배열, 마지막으로 소자 내부의 포인터를 이동하고, 출력
  • next() - 배열, 다음 요소를 내부에 포인터를 이동하고, 출력
  • prev() - 배열, 이전 요소를 내부에 포인터를 이동하고, 출력
  • each() - 현재 요소의 키 값을 반환하고, 전방 내부 포인터 이동

통사론

reset( array )

매개 변수 기술
array 필요합니다. 사용하는 배열을 지정합니다

기술적 세부 사항

반환 값 : 성공에 배열의 첫 번째 요소의 값을 돌려 배열이 비어 FALSE 인 경우
PHP 버전 : 4+

더 예

예 1

관련된 모든 방법을 데모 :

<?php
$people = array("Peter", "Joe" , "Glenn" , "Cleveland");

echo current($people) . "<br>"; // The current element is Peter
echo next($people) . "<br>"; // The next element of Peter is Joe
echo current($people) . "<br>"; // Now the current element is Joe
echo prev($people) . "<br>"; // The previous element of Joe is Peter
echo end($people) . "<br>"; // The last element is Cleveland
echo prev($people) . "<br>"; // The previous element of Cleveland is Glenn
echo current($people) . "<br>"; // Now the current element is Glenn
echo reset($people) . "<br>"; // Moves the internal pointer to the first element of the array, which is Peter
echo next($people) . "<br>"; // The next element of Peter is Joe

print_r (each($people)); // Returns the key and value of the current element (now Joe), and moves the internal pointer forward
?>
»실행 예

<PHP 배열 문헌