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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 09:51:41
Original
1167 people have browsed it

How to use PHP to loop table to display one row and two columns, table with two columns

<table width="100%" border="0" cellspacing="1" cellpadding="0" style="background:#CCC">
 <tr>
  <td align="center" bgcolor="#FFFFFF">第一列</td>
  <td align="center" bgcolor="#FFFFFF">第二列</td>
 </tr>
 <tr>
  <&#63;php
   $setarr = array(0,1,2,3,4,5,6,7,8,9); //相当于数据库获取的数组
 $i=0;
 foreach($setarr as $val){
  $i++;
 &#63;>
   <&#63;=$val&#63;>
  <&#63;php 
 if($i%2==0&&$i<count($setarr)) echo '</tr><tr>';
 
 } &#63;>
 </tr>
</table>
Copy after login

For example: if it is other character types, you need to use function conversion:

<&#63;php
$str = "Hello world. It's a beautiful day.";
print_r (explode(" ",$str));
&#63;>
Copy after login

Result:

Array
(
[0] => Hello
[1] => world.
[2] => It's
[3] => a
[4] => beautiful
[5] => day.
)

Copy after login

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1011951.htmlTechArticlephp loop table to achieve one row and two columns display, table two columns table width="100%" border=" 0" cellspacing="1" cellpadding="0" style="background:#CCC" tr td align="center" bgcolor="#F...
Related labels:
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template