加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > PHP > 正文

PHP中的函数---reset()的用法

发布时间:2020-05-25 02:50:52 所属栏目:PHP 来源:互联网
导读:一、reset 将数组的内部指针指向第一个单元mixed reset ( array $array )reset() 将 array 的内部指针倒回到第一个单元并返回第一个数组单元的值,如果数组为空则返回 FALSE。Example #1 reset() 例子?php$array = array(step one, step two, step three, ste

<p class="refpurpose"><span style="font-size: 14px; font-family: arial,helvetica,sans-serif;"><span class="refname">一、reset — <span class="dc-title">将数组的内部指针指向第一个单元


<div class="cnblogs_code">



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

Example #1 reset() 例子

$array = array(<span style="color: #800000;">'<span style="color: #800000;">step one<span style="color: #800000;">',<span style="color: #800000;">'<span style="color: #800000;">step two<span style="color: #800000;">',<span style="color: #800000;">'<span style="color: #800000;">step three<span style="color: #800000;">',<span style="color: #800000;">'<span style="color: #800000;">step four<span style="color: #800000;">'<span style="color: #000000;">);

<span style="color: #008000;">//<span style="color: #008000;"> by default,the pointer is on the first element
echo current($array) . <span style="color: #800000;">"<span style="color: #800000;">
n<span style="color: #800000;">"; <span style="color: #008000;">//<span style="color: #008000;"> "step one"

<span style="color: #008000;">//<span style="color: #008000;"> skip two steps
<span style="color: #000000;">next($array);
next($array);
echo current($array) . <span style="color: #800000;">"<span style="color: #800000;">
n<span style="color: #800000;">"; <span style="color: #008000;">//<span style="color: #008000;"> "step three"

<span style="color: #008000;">//<span style="color: #008000;"> reset pointer,start again on step one
<span style="color: #000000;">reset($array);
echo current($array) . <span style="color: #800000;">"<span style="color: #800000;">
n<span style="color: #800000;">"; <span style="color: #008000;">//<span style="color: #008000;"> "step one"

?>

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读