Home > Backend Development > PHP Tutorial > How to use php current function

How to use php current function

藏色散人
Release: 2023-04-05 07:10:01
Original
2771 people have browsed it

PHP current() function is used to return the current unit in the array. Its syntax is current(array). The parameter array is required and refers to the array to be used.

How to use php current function

#How to use php current function?

php current() function syntax

Function: Return the value of the current element in the array.

Syntax:

current(array)
Copy after login

Parameters:

array Required. Specifies the array to use.

Description:

Returns the value of the current element in the array. Each array has an internal pointer pointing to its "current" element, initially pointing to the first element inserted into the array.

php current() function usage example 1

<?php
$people = array("西门", "灭绝", "无忌");
echo current($people);
?>
Copy after login

Output:

西门
Copy after login

php current() function usage example 2

<?php
$arr = array("peter", "灭绝", "欧阳克");
echo current($arr);
?>
Copy after login

Output:

peter
Copy after login

This article is an introduction to the PHP current function. I hope it will be helpful to friends in need!

The above is the detailed content of How to use php current function. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template