通过PHP current函数获取未知字符键名数组第一个元素的值_PHP教程

WBOY
Release: 2016-07-21 15:03:11
Original
710 people have browsed it

关于current()函数:

每个数组中都有一个内部的指针指向它“当前的”单元,初始指向插入到数组中的第一个单元。用current()获取。

类似函数:

end() 将array的内部指针移动到最后一个单元并返回其值。

next()返回数组内部指针指向的下一个单元的值,或当没有更多单元时返回FALSE。

prev()返回数组内部指针指向的前一个单元的值,或当没有更多单元时返回FALSE。

reset() 将array的内部指针倒回到第一个单元并返回第一个数组单元的值,如果数组为空则返回FALSE。

看下面PHP案例:

复制代码 代码如下:

$arr = array("a"=>"php","java","c");
echo current($arr); //php
echo next($arr); //java
echo prev($arr); //php 指向上一单元的值,所以又为php了
echo end($arr); //c
?>


很好用且很有用的几个php函数,反正我是记住了。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/327867.htmlTechArticle关于current()函数: 每个数组中都有一个内部的指针指向它“当前的”单元,初始指向插入到数组中的第一个单元。用current()获取。 类似函数...
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!