How to Mask a Credit Card Number in Laravel
In this lesson, we are going to see how to mask a credit card number in Laravel, the mask helper method is used to hide a part of a string.
The Str::mask helper method
The mask() method is used to hide a part of a string, the best example for the application of this helper is to display the last four digits of a credit card number.
use Illuminate\Support\Str;
Str::mask('4242424242424242', '*', 0, -4);
// Returns "************4242"