Home >Backend Development >PHP Tutorial >How to loop table in php to display one row and two columns_PHP tutorial

How to loop table in php to display one row and two columns_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:52:071029browse

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 ;

?>

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

89 10 11 12 13 14
15
16
17 18 19
<🎜>$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 ;<🎜> <🎜>?> '; } ?>
First column Second column
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...
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