1

我需要从管理功能中隐藏某些帐户。

目前,为管理员列出了 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>";
}

如何创建一个循环来隐藏某些电子邮件不显示?

4

1 回答 1

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
}
于 2012-07-16T16:42:51.540 回答