fork download
  1. <?php
  2.  
  3. echo masked_ip( '192.168.0.1' ) . PHP_EOL;
  4. echo masked_ip( '192.168.10.31' ) . PHP_EOL;
  5. echo masked_ip( '192.168.12.132' ) . PHP_EOL;
  6.  
  7. function masked_ip( $ip ) {
  8. $ocs = explode( '.', $ip );
  9. $ocs[2]{strlen($ocs[2])-1} = '*';
  10. $ocs[3]='***';
  11. return implode( '.', $ocs );
  12. }
  13.  
Success #stdin #stdout 0s 52488KB
stdin
Standard input is empty
stdout
192.168.*.***
192.168.1*.***
192.168.1*.***