3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function callback($s) { return substr_replace($s[0], str_repeat('*', strlen($s[0])), 0, -4); } $values = array( '5746244234383238', '746244234383238', '46244234383238', '6244234383238', '244234383238', '44234383238', ); foreach ($values as $value) var_dump(preg_replace_callback('/\d{12,16}/', 'callback', $value));
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
string(20) "****************3238" string(19) "***************3238" string(18) "**************3238" string(17) "*************3238" string(16) "************3238" string(11) "44234383238"