-2

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

Brian Millot
  • 179
  • 1
  • 12

2 Answers2

0
$string = '005390326548';
$retult = substr($string, 0, 4) . '****' . substr($string, 8);
W S
  • 362
  • 3
  • 4
0

one-liner solution.

$string= substr_replace("8487013103", "****", 4, 4);
echo $string;