'How can i replace a portion of string starting from the next 4 characters? [duplicate]
I have the below string:
$string = 005390326548;
How can i get this result?
0053****6548
Basically i want to replace starting from the 4 characters the next 4 characters by ****
Solution 1:[1]
one-liner solution.
$string= substr_replace("8487013103", "****", 4, 4);
echo $string;
Solution 2:[2]
$string = '005390326548';
$retult = substr($string, 0, 4) . '****' . substr($string, 8);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Vlad Salabun |
