我有一个表格列出了几个元素及其到期日期.
我需要一个函数,说"如果到期日期晚于今天(对于每个元素),那么就不要显示".
看起来很简单,但我被卡住了!
编辑
<?php foreach($codes->result_array() as $row):?>
<tr>
<td><?php print $row['description']?></td>
<td><?php print $row['credits']?></td>
<td><?php print $row['code']?></td>
<td><? echo date("F jS, Y", strtotime($row['exp_date']));?></td>
<td><? echo date("F jS, Y", strtotime($row['create_date']));?></td>
<td>
<!-- Icons -->
<a href="<? echo base_url()?>admin/home/editCode/<?php print $row['id']?>" title="Edit"><img src="<? echo base_url()?>assets/images/icons/pencil.png" alt="Edit" /></a>
<a href="<? echo base_url()?>admin/home/deleteCode/<?php print $row['id']?>" title="Delete" class="delete-code"><img src="<? echo base_url()?>assets/images/icons/cross.png" alt="Delete" /></a>
</td>
<?php endforeach;?>
Run Code Online (Sandbox Code Playgroud)
这是一个非常基本的例子.
foreach($elements as $element)
{
if(strtotime($element['expiration_date']) < now())
{
echo $element['expiration_date'];
}
}
Run Code Online (Sandbox Code Playgroud)