The method of php looping table to realize one row and two columns display
This article mainly introduces the method of php looping table to realize one row and two columns display. This article directly gives the implementation code, the key points It is the application of the remainder method. Friends who need it can refer to it
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
第一列 |
第二列 |
$setarr = array(0,1,2,3,4,5,6,7,8,9); //相当于数据库获取的数组
$i=0;
foreach($setarr as $val){
$i ;
?>
=$val?>
if($i%2==0&&$i';
} ?>
|
1
2
3
1
2
3
4
|
$str = "Hello world. It's a beautiful day.";
print_r (explode(" ",$str));
?>
|
4
5
1
2
3
4
5
6
7
8
9
|
Array
(
[0] => Hello
[1] => world.
[2] => It's
[3] => a
[4] => beautiful
[5] => day.
)
|
6
7
8
9
10
11
12
13
14
15
17
18
19
|
First column |
Second column |
<🎜>$setarr = array(0,1,2,3,4,5,6,7,8,9); //Equivalent to the array obtained from the database<🎜>
<🎜>$i=0;<🎜>
<🎜>foreach($setarr as $val){<🎜>
<🎜>$i ;<🎜>
<🎜>?>
=$val?>
';
} ?>
|
For example: if it is other character types, you need to use function conversion:
?
1
2
3
4
|
<🎜>$str = "Hello world. It's a beautiful day.";<🎜>
<🎜>print_r (explode(" ",$str));<🎜>
<🎜>?>
|
Result:
?
1
2
3
4
5
6
7
8
9
|
Array
(
[0] => Hello
[1] => world.
[2] => It's
[3] => a
[4] => beautiful
[5] => day.
)
|
http://www.bkjia.com/PHPjc/1011119.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1011119.htmlTechArticleHow to achieve one row and two column display in php loop table. This article mainly introduces the method of php loop table to achieve one row and two column display. method, this article directly gives the implementation code, the focus is on the remainder method...