PHP 전류 () 함수
예
출력 전류 배열 요소 값 :
<?php
$people = array("Peter", "Joe", "Glenn", "Cleveland");
echo current($people) . "<br>";
?>
$people = array("Peter", "Joe", "Glenn", "Cleveland");
echo current($people) . "<br>";
?>
»인스턴스를 실행
정의 및 사용
전류 () 함수는 상기 어레이의 현재 요소의 값을 반환한다.
각 배열은 "현재"요소 배열의 첫 번째 요소에 삽입하는 초기 시점에 내부 포인터가 있습니다.
팁 :이 기능은 내부 배열 포인터를 이동하지 않습니다.
관련 방법 :
- 종료 () - 배열, 출력의 마지막 요소에 대한 내부 포인터.
- 다음 () - 다음 배열의 요소를 출력하도록 내부 포인터.
- 상기 PREV () - 배열, 출력의 마지막 요소에 대한 내부 포인터.
- RESET () - 배열, 출력의 첫 번째 요소에 대한 내부 포인터.
- 각 () - 현재 요소의 키 이름과 값을 반환하고, 내부 포인터가 앞으로 이동합니다.
문법
current( 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 배열 참조