PHP 이전 () 함수
예
배열, 다음의 요소와 가치의 요소에서 현재 요소의 출력 :
<?php
$people = array("Peter", "Joe", "Glenn", "Cleveland");
echo current($people) . "<br>";
echo next($people) . "<br>";
echo prev($people);
?>
$people = array("Peter", "Joe", "Glenn", "Cleveland");
echo current($people) . "<br>";
echo next($people) . "<br>";
echo prev($people);
?>
»인스턴스를 실행
정의 및 사용
마지막 배열의 요소를 출력하도록 이전 () 함수 내부 포인터.
관련 방법 :
- 다음 () - 다음 배열의 요소를 출력하도록 내부 포인터.
- 현재 () - 배열의 현재 요소의 값을 돌려줍니다.
- 종료 () - 배열, 출력의 마지막 요소에 대한 내부 포인터.
- RESET () - 배열, 출력의 첫 번째 요소에 대한 내부 포인터.
- 각 () - 현재 요소의 키 이름과 값을 반환하고, 내부 포인터가 앞으로 이동합니다.
문법
prev( 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
?>
$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 배열 참조