Home  >  Article  >  Backend Development  >  php 中怎么表示循环数组的总数

php 中怎么表示循环数组的总数

WBOY
WBOYOriginal
2016-06-13 12:14:411208browse

php 中如何表示循环数组的总数

本帖最后由 chinaphp2010 于 2015-01-28 13:18:14 编辑 前提是for循环
比如这个循环中有N次
那么如何计算得到N这个值呢
当然很多人会说用$num=0;$num++;
 这个是可以的,但不适合我的需求,
我的需求是直接在for循环中显示这个数
for($i=0;$i     循环总数*$i
}
要是这样,你在里面用$num=0;$num++;这种方法就不行了,
------解决思路----------------------
一般是这样的

for($i=0;$i     count($arr)*$i
}
Statement:
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