Blogger Information
Blog 7
fans 0
comment 0
visits 8141
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
foreach.if 控制替代语法
dongfeng的博客
Original
841 people have browsed it

$employee = [

['id'=>1, 'name'=>'关羽', 'age'=>40, 'sex'=>1,  ' hiredate'=> time()],

['id'=>2, 'name'=>'张飞', 'age'=>40, 'sex'=>1,   'hiredate'=> time()],

['id'=>3, 'name'=>'赵子龙', 'age'=>50, 'sex'=>1, 'hiredate'=> time()],

['id'=>4, 'name'=>'曹总', 'age'=>45, 'sex'=>1,   'hiredate'=> time()],

['id'=>5, 'name'=>'貂蝉', 'age'=>18, 'sex'=>0,   'hiredate'=> time()],

];


<!--foreach()替代语法-->

<?php foreach($employee as $emp) : ?>

<tr>


<td><?php echo $emp['id']; ?></td>

<td>

<?php echo $emp['name']; ?>

</td>



<td>

<?php echo $emp['age']; ?>

</td>


<!--if()替代语法-->

<td>

<?php if($emp['sex'] == 1) : ?>

<?php else: ?>

<?php endif; ?>

</td>



<!--如果只是简单的输出变量可以使用php短标签语法-->

<td>

<?php

//echo date('Y/m/d',$emp['hiredate']);

?>

</td>


<td>

<button onclick="location.href='#'">增加</button>

<button onclick="location.href='#'">查询</button>

<button onclick="location.href='#'"><span style="color:red">删除</span></button>

</td>


</tr>

<?php endforeach;?>


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