What is the usage of each in php

WBOY
Release: 2023-03-15 22:00:01
Original
1836 people have browsed it

In PHP, the each() function is used to return the key name and key value of the current element and move the internal pointer forward; this function can generate an element key name and key pointed to by the current internal pointer of the array An array composed of values. If the internal pointer exceeds the range of the array, the function returns false and the syntax is "each (array)".

What is the usage of each in php

The operating environment of this article: Windows 10 system, PHP version 5.6, Dell G3 computer

What is the usage of each in php

each() function returns the key name and key value of the current element and moves the internal pointer forward.

The key name and key value of the element will be returned in an array with four elements. Two elements (1 and Value) contain the key value, and two elements (0 and Key) contain the key name.

each(array)
Copy after login

array Required. Specifies the array to use.

Description

each() function generates an array consisting of the key name and key value of the element pointed to by the current internal pointer of the array, and moves the internal pointer forward.

The returned array includes four elements: key names 0, 1, key and value. Cells 0 and key contain the key names of the array cells, and 1 and value contain the data.

If the internal pointer exceeds the range of the array, this function will return FALSE.

The example is as follows:

    $val
"; } ?>
Copy after login

Output result:

What is the usage of each in php

Tips: each() function is in PHP 7.2. Deprecated in 0.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What is the usage of each in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!