我需要隐藏管理功能中的某些帐户。
目前,管理员列出了eash帐户。但是,我希望所有的电子邮件都以gmail.com隐藏,直到我要求将它们与其他人一起列出。
这是我的电子邮件的代码:
if(empty($resLine['ord_conEmail'])){
$resLine['ord_conEmail'] = "Account {$resLine['ord_account']}";
}
代码中较大的代码是:
$buffer .= "
<div id=\"catDetail\">
<h1>Orders Listing$pnStr</h1>
<div>
<table class=\"roundTableFormat\">
<thead>
<tr>
<th>Order ID</th>
<th>Order Date</th>
<th>Cust. Email Address</th>
<th>Order Total</th>
<th>Actions</th>
</tr>
</thead>
<tbody>";
forEach($res as $resLine){
if($resLine['ord_date'] > mktime() - 86400){
//24 hours
$resLine['ord_date'] = date("D jS - g:iA", $resLine['ord_date']);
}else if($resLine['ord_date'] > mktime() - 259200){
//OLD:display Day of Week for last five days (60*60*24*5=432000 sec
//New: 3 days = 259200
$resLine['ord_date'] = date("D jS - g:iA", $resLine['ord_date']);
}else{
//display full date
$resLine['ord_date'] = date("M j, Y", $resLine['ord_date']);
}
$resLine['ord_total'] = "$".number_format($resLine['ord_total'], 2);
if(empty($resLine['ord_conEmail'])){
$resLine['ord_conEmail'] = "Account {$resLine['ord_account']}";
}
$buffer .= "
<tr>
<td class=\"ds br\">{$resLine['ord_id']}</td>
<td class=\"al ls br\">{$resLine['ord_date']}</td>
<td class=\"al ls\">{$resLine['ord_conEmail']}</td>
<td class=\"ar bl br\">{$resLine['ord_total']}</td>
<td class=\"ds \">
<a href=\"?action=orders&ordview={$resLine['ord_id']}\">View</a>
<a href=\"?action=orders&ordprint={$resLine['ord_id']}\">Print</a>
</td>
</tr>";
}
如何创建循环以隐藏某些电子邮件?
答案 0 :(得分:0)
您可以添加一个哈希表(关联数组)来存储要忽略的电子邮件域。
$domains = array(
'gmail.com' => true
);
您可以添加一个条件语句来检查域是否已设置。它将在缓冲要打印的html的行之前插入。
$email = $resLine['ord_conEmail'];
// Assumes e-mail address is correctly formatted: user@domain
$result = explode('@', $email);
$domain = $result[1];
if (isset($domains[$domain]) && $domains[$domain]) {
continue; // Skip row
}