fork(1) download
  1. <?php
  2.  
  3. $replacer = static function ($m) {
  4. return str_repeat('*', strlen($m[1])) . '.' . str_repeat('*', strlen($m[2]));
  5. };
  6.  
  7.  
  8. $ips = ['127.0.0.1', '127.0.0.100', '127.0.100.0'];
  9.  
  10. foreach ($ips as $ip) {
  11. $results[] = preg_replace_callback('/(\d{1})\.(\d{1,3})$/', $replacer, $ip);
  12. }
  13.  
  14. print_r($results);
Success #stdin #stdout 0.01s 52488KB
stdin
Standard input is empty
stdout
Array
(
    [0] => 127.0.*.*
    [1] => 127.0.*.***
    [2] => 127.0.10*.*
)