Laravel  
laravel
文档
数据库
架构
入门
php技术
    
Laravelphp
laravel / php / java / vue / mysql / linux / python / javascript / html / css / c++ / c#

each() php

作者:资本principal   发布日期:2025-09-19   浏览:349

The each() function in PHP is used to fetch the key-value pair from an array and move the internal pointer of the array forward. It returns the current key-value pair and moves the pointer to the next pair.

Here is the syntax of the each() function:

each(array $array): array|false

Parameters:

  • $array: The input array.

Return Value:

  • An array containing the current key-value pair from the input array, or false if there are no more elements in the array.

Example:

$fruits = array("apple", "banana", "orange");

$fruit = each($fruits);
print_r($fruit);

Output:

Array
(
    [1] => apple
    [value] => apple
    [0] => 0
    [key] => 0
)

In the above example, the each() function returns the first key-value pair from the $fruits array. The returned array contains the value (apple), the key (0), and their respective indexes (1 and 0).

上一篇:数组处理函数php(c语言数组处理函数)

下一篇:php strpos

大家都在看

php session用法

php 定义常量

phpisset函数

php html转图片

php后端

php爬虫框架

php读取csv文件

php 三元表达式

php文件加密

php 判断是否为空

Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3

Laravel 中文站