Let's take a look at what "%" means in this code $ col4; $ index0; $ pai_displayarray (); foreach ($ pai_listas $ share) {$ mod $ index % $ col; $ pai_display [col. $ mod] [] $ share; let's take a look at the meaning of "%" in this code.
$ Col = 4;
$ Index = 0;
$ Pai_display = array ();
Foreach ($ pai_list as $ share)
{
$ Mod = $ index % $ col;
$ Pai_display ['col'. $ mod] [] = $ share;
$ Index ++;
}
I don't quite understand. it seems like this code means that the array is divided into four sub-arrays by The Shard _list and assigned to the Shard _display.
------ Solution --------------------
$ Index % $ col get $ index divided by the remainder of $ col
------ Solution --------------------
Remainder'
------ Solution --------------------
Do you have never learned to calculate the remainder?
------ Solution --------------------
Yes, the array $ arrays _list is scattered into four sub-arrays.
------ Solution --------------------
Discussion
I checked it and said it was a modulo operator. However, the result of the value I got is $ pai_display ['col'. $ mod] []. only col has four items.
In this case, the value of $ mod has always been in the 0123 loop, but there are a total of 40 values under $ Every _list, and the values from 40 to 4 are all counted as 10.
------ Solution --------------------
Remainder 3
------ Solution --------------------
All the arithmetic problems in elementary school are called remainder!
------ Solution --------------------
The modulo operation is to calculate the remainder.