我正在尝试做一些研究,但没有找到我正在寻找的东西。我正在使用Codeigniter
andHTML Table Class
并试图找出在事件 $inbox_messages 是一个空数组时我应该在我的代码中做什么。这样做的原因是因为我在 if 语句中将表格中的表格标题和单元格数据放在了一起。如果它是一个空数组,我不确定该怎么做,因为在我的视图文件中我告诉它生成表。
// Retrieve all user inbox messages that have not been deleted by the user..
$inbox_messages = array();
// Place to dump the inbox messages object variable to verify it is the expected properties and values for the inbox messages object.
// vardump($inbox_messages);
// Check to see if there are messages returned in the inbox messages object.
if (!empty($inbox_messages))
{
// Add headings to the top of the table for the inbox messages html table.
$this->table->set_heading(form_checkbox(), 'Date Sent', 'Subject', 'From');
// Loop through the inbox messages object and display data for each row.
foreach ($inbox_messages AS $message)
{
$this->table->add_row(form_checkbox(), date('F d, Y', strtotime($message->date_sent)), $message->subject, $message->first_name . ' ' . $message->last_name);
}
}
else
{
// Figure out what to do if object is empty
}