This article mainly introduces the PHP loop table to achieve a row of two columns to display the method, this article directly to the implementation of code, the emphasis is on the use of complementary methods, the need for friends can refer to the
?
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<table width= "100%" border= "0" cellspacing= "1" cellpadding= "0" style= "background: #CCC" > <tr> <td align= "Center" bgcolor= "#FFFFFF" > First column </td> <td align= "center" bgcolor= "#FFFFFF" > second column </td> </tr> <tr> <?php $setarr = Array (0,1,2,3,4,5,6,7,8,9); The equivalent of a database-acquired array $i = 0; foreach ($setarr as $val) {$i + +;?> <?= $val?> <?php if ($i%2==0&& $i <count ($setarr)) echo ' </tr& Gt;<tr> '; }?> </tr> </table> |
Such as: is other character type, need to use function transformation:
?
| 1 2 3 4 |
<?php $str = "Hello world." It ' s a beautiful day. "; Print_r (Explode ("", $str));?> |
Results:
?
| 1 2 3 4 5 6 7 8 9 |
Array ([0] => Hello [1] => world. [2] => It ' s [3] => a [4] => beautiful [5] => day. ) |