大家帮小弟我看下这段代码中的“%”是什么意思

WBOY
Release: 2016-06-13 13:34:33
Original
1689 people have browsed it

大家帮我看下这段代码中的“%”是什么意思
$col = 4;
$index = 0;
$share_display = array();
foreach($share_list as $share)
{
$mod = $index % $col;
$share_display['col'.$mod][] = $share;
$index++;
}

不是很明白 ,,好像这个代码的意思是,将数组分SHARE_LIST打散成四个子数组赋给SHARE_DISPLAY

------解决方案--------------------
$index% $col 得到$index除以$col的余数
------解决方案--------------------
取余 `
------解决方案--------------------
求余数,你没学过算数吗?
------解决方案--------------------
对呀,数组 $share_list 被分散到 4 个子数组中去了
------解决方案--------------------

探讨

我查了下,说是取模运算符,不过,我得到的数值结果是$share_display['col'.$mod][]下只有COL只有4个项

这么说$mod的值一直是在0123循环了,,可$share_list下一共有40个值,,,40除4都到10了

------解决方案--------------------
求余数三
------解决方案--------------------
小学的算术问题,都说是取余啦啊!
------解决方案--------------------
取模运算就是求余数
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