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

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

Jun 13, 2016 pm 01:34 PM
display index list share

大家帮我看下这段代码中的“%”是什么意思
$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了

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What file is index.html? What file is index.html? Feb 19, 2024 pm 01:36 PM

index.html represents the home page file of the web page and is the default page of the website. When a user visits a website, the index.html page is usually loaded first. HTML (HypertextMarkupLanguage) is a markup language used to create web pages, and index.html is also an HTML file. It contains the structure and content of a web page, as well as tags and elements used for formatting and layout. Here is an example index.html code: &lt

Fujifilm X-M5 price expectations rise as leaked selfie display adds complexity to the formerly affordable camera line Fujifilm X-M5 price expectations rise as leaked selfie display adds complexity to the formerly affordable camera line Sep 07, 2024 am 09:34 AM

Fujifilm fans were recently very excited at the prospect of the X-T50, since it presented a relaunch of the budget-oriented Fujifilm X-T30 II that had become quite popular in the sub-$1,000 APS-C category. Unfortunately, as the Fujifilm X-T50's launc

Ubisoft share falls to 10-year low after disappointing launch of Star Wars: Outlaws Ubisoft share falls to 10-year low after disappointing launch of Star Wars: Outlaws Sep 07, 2024 am 06:30 AM

The shares of the French video game developer Ubisoft reached a record low on Thursday. At a price of around 15.50 euros per share, the value has plummeted by around 10%. As a result, the company's market capitalization fell below 2 billion euros. In

Samsung: New, large display based on E Ink technology displays colors and communicates wirelessly Samsung: New, large display based on E Ink technology displays colors and communicates wirelessly Jun 19, 2024 pm 03:37 PM

We frequently report on devices based on displays with electronic ink, such as e-readers. The technology offers a number of advantages: it can be read in bright environments without a backlight, and it only requires power when switching without light

Comparison: Apple Studio Display vs Samsung Smart Monitor M8 Comparison: Apple Studio Display vs Samsung Smart Monitor M8 May 11, 2023 pm 10:46 PM

Samsung Smart Display M8 vs. Apple Studio Display: Design and Size Since its launch, the Apple Studio Display has been compared to the iMac, consisting of a relatively thin panel on a relatively simple L-shaped stand. It's a well-known and well-loved aesthetic, and Samsung seems to have borrowed it for its presentation. The Samsung SmartMonitor M8 uses the same idea of ​​a thin screen on a stand that looks very similar. Some minor elements are different, such as the small section in the lower left corner that sticks out a bit and the Samsung's chin is very thin, but they seem to be close in terms of basic design. Samsung seems to have taken a lot of inspiration from the 24-inch iMac. Apple's display is smaller than Samsung's

Apple Studio Display's power cord is detachable, but requires special tools Apple Studio Display's power cord is detachable, but requires special tools May 17, 2023 pm 03:05 PM

Apple Studio Display is now officially available in stores, and many customers around the world have purchased the product. Unlike the ProDisplayXDR, the StudioDisplay has a unique power connector that appears to be non-removable. It turns out that the cable is removable, but you'll need a special tool to remove it. Apple says on its website that the Studio Display's power cord is not detachable -- and many users think so. That's because removing the cable with your hands seems impossible, but luckily the cable can be detached from the monitor. , Apple has a special tool for extracting information from its new StudioDispl

Ubisoft shares fall to 10-year low after disappointing launch of Star Wars: Outlaws Ubisoft shares fall to 10-year low after disappointing launch of Star Wars: Outlaws Sep 08, 2024 am 06:36 AM

The shares of the French video game developer Ubisoft reached a record low on Thursday. At a price of around 15.50 euros per share, the value has plummeted by around 10%. As a result, the company's market capitalization fell below 2 billion euros. In

How to implement Redis List operation in php How to implement Redis List operation in php May 26, 2023 am 11:51 AM

List operation //Insert a value from the head of the list. $ret=$redis->lPush('city','guangzhou');//Insert a value from the end of the list. $ret=$redis->rPush('city','guangzhou');//Get the elements in the specified range of the list. 0 represents the first element of the list, -1 represents the last element, and -2 represents the penultimate element. $ret=$redis->l

See all articles