mask() - before() - after()
use Illuminate\Support\Str;
$str = 'marcosgaad@gmail.com';
Str::mask($str, '*', 4); // marc****************
Str::mask($str, '*', 4, 3); // marc***aad@gmail.com
Str::mask($str, '*', -4); // marcosgaad@gmail****
Str::mask($str, '*', -4, 3); // marcosgaad@gmail***m
$before = Str::before($str, '@'); // marcosgaad
Str::mask($before, '*', 0) . '@' . Str::after($str, '@'); // **********@gmail.com
I hope you enjoy the code.
Top comments (1)
great !