Hướng dẫn dùng nextelementsibling trong PHP

  • Trang chủ
  • Phát triển web
  • PHP
  • Hàm next[] trong PHP

Hướng dẫn cách sử dụng hàm next[] về mảng trong lập trình PHP

Nội dung chính

  • Tác dụng của hàm next[]
  • More Examples
  • Bài viết này đã giúp ích cho bạn?
  • Bài viết mới
  • 1. nextSibling javascript là gì?
  • 2. Cách dùng nextSibling trong javascript

Tác dụng của hàm next[]

The next[] function moves the internal pointer of an array to the next element, and returns its value.

The following table summarizes the technical details of this function.

Return Value:Version:
Returns the value of the next element in the array, or FALSE if there are no more elements.
PHP 4+

Tip: Every array has an internal pointer that points to the current element in the array. When a new array is created, the current pointer is initialized to reference the first element in the array.

Syntax

The basic syntax of the next[] function is given with:

The following example shows the next[] function in action.

Parameters

The next[] function accepts the following parameters.

ParameterDescription
array Required. Specifies the array to work on.

More Examples

Here're some more examples showing how next[] function actually works:

The following example demonstrates how to get the next value from an associative array:

The next[] function is commonly used along with the following functions:

  • current[] – Returns the value of the current element in an array.
  • end[] – Moves the internal pointer of an array to its last element, and returns its value.
  • prev[] – Moves the internal pointer of an array to the previous element, and returns its value.
  • reset[] – Set the internal pointer of an array to its first element, and returns its value.
  • key[] – Returns the key of the current element in an array.

Here's an example that demonstrates how these functions basically work:

Chủ Đề