我有一个表,显示一些数据钱包地址或电子邮件。
我需要什么时候是电子邮件,然后隐藏字母@像这样****@gmail.com
我的表在前端php是:
<table class="table table-striped text-center"><thead><tr>
<th scope="col">Username</th>
<th scope="col">Address</th>
</tr>
</thead>
<tbody>
<?php
foreach ($withdrawHistory as $wd) {
echo '<tr><td>' . $wd["username"] . '</td>
<td>' . $wd["wallet"] . '</td>
</tr>'; }?> </tbody></table>
有办法隐藏吗?
<table class="table table-striped text-center"><thead><tr>
<th scope="col">Username</th>
<th scope="col">Address</th>
</tr>
</thead>
<tbody>
<?php
foreach ($withdrawHistory as $wd) {
echo '<tr><td>' . $wd["username"] . '</td>
<td>' . '****'.strstr($wd["wallet"], '@') . '</td>
</tr>'; }?> </tbody></table>
一种方法是使用explosion(在foreach循环中),然后只返回$email。
$wallet = explode("@", $wd["wallet"]);
$email = "****@". $wallet[1];
echo $email;
如果你想要@前面的字母个数匹配*的个数,使用这个
$wallet = explode("@", $wd["wallet"]);
$y = strlen($wallet[0]);
$hidden = "";
for ($x = 1; $x <= $y; $x++) {
$hidden .= "*";
}
$email = $hidden ."@". $wallet[1];
echo $email;