mask.php
Table of Contents
Functions
- mask() : string
- Masks the middle part of a string, keeping a few grapheme clusters visible at each end.
Functions
mask()
Masks the middle part of a string, keeping a few grapheme clusters visible at each end.
mask(string $source[, int $visibleStart = 0 ][, int $visibleEnd = 4 ][, string $char = '*' ]) : string
Useful for hiding sensitive data (emails, tokens, card numbers). The first
$visibleStart and last $visibleEnd grapheme clusters are kept, every grapheme
in between is replaced by $char. When the visible regions cover (or overlap) the
whole string, there is nothing to hide and the original string is returned unchanged.
Parameters
- $source : string
-
The input string.
- $visibleStart : int = 0
-
The number of leading grapheme clusters to keep visible. Default
0. - $visibleEnd : int = 4
-
The number of trailing grapheme clusters to keep visible. Default
4. - $char : string = '*'
-
The masking character. Default
*.
Tags
Return values
string —The masked string.