Blogger Information
Blog 15
fans 0
comment 0
visits 12601
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php表格
峰回掠影的博客
Original
1499 people have browsed it

实例

<?php
$arr = [
		['id' => 1 , 'name'=>'123','age' => '35','sex'=>'1'],
		['id' => 2 , 'name'=>'456','age' => '34','sex'=>'0'],
		['id' => 3 , 'name'=>'789','age' => '43','sex'=>'1'],
		['id' => 4 , 'name'=>'110','age' => '56','sex'=>'0'],
	];

	//数组总数量
	$Total  = count($arr);
	//标题
	$tit = '用户表'
	//浏览器title
	// $ttit = $tit;


?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title><?php $ttit ?></title>
</head>
<body>
	<table>
		<thead>
			<tr>
				<th>ID</th>
				<th>名字</th>
				<th>年龄</th>
				<th>性别</th>
			</tr>
		</thead>
		<tbody>
			$tab = '';
		
			<?php 
				foreach ($arr as $k) {
				  $tab .= '<tr>';
				  $tab .='<td>'.$k{'id'}.'</td>';
				  $tab .='<td>'.$k{'name'}.'</td>';
				  $tab .='<td>'.$k{'age'}.'</td>';
				  $tab .='<td>'.($k{'sex'} ? '男' : '女').'</td>';
				  $tab .='</tr>';
				}

			echo $tab;	
			?>
			
		</tbody>总数是
			<?php  echo $Total; ?>
	</table>

	
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

 

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post