-1

I have a table that show some data wallet address or email.

I need when is email then hide the letters before @ like this ****@gmail.com

My table in the frontent php is:

<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>

Is there a way to hide ?

2 Answers2

0

One way to do this is by using explode (inside the foreach loop) and then just echo $email.

$wallet = explode("@", $wd["wallet"]);

$email = "****@". $wallet[1];

echo $email;

If you want the number of letters before @ match the number of * use this.

$wallet = explode("@", $wd["wallet"]);

$y = strlen($wallet[0]);

$hidden = "";

for ($x = 1; $x <= $y; $x++) {
   $hidden .= "*";
}

$email = $hidden ."@". $wallet[1];

echo $email;
0
<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>
dev_mustafa
  • 1,042
  • 1
  • 4
  • 14