title: Partially hide email address in PHP
body: <p>I am building a simple friend/buddy system, and when someone tries to search for new friends, I want to show partially hidden email addresses, so as to give an idea about who the user might be, without revealing the actual details.</p>
  
  <p>So I want <code>abcdlkjlkjk@hotmail.com</code> to become <code>abcdl******@hotmail.com</code>.</p>
  
  <p>As a test I wrote:</p>
  
  <pre><code>&lt;?php
  $email = "abcdlkjlkjk@hotmail.com";
  
  $em = explode("@",$email);
  $name = $em[0];
  $len = strlen($name);
  $showLen = floor($len/2);
  $str_arr = str_split($name);
  for($ii=$showLen;$ii&lt;$len;$ii++){
      $str_arr[$ii] = '*';
  }
  $em[0] = implode('',$str_arr); 
  $new_name = implode('@',$em);
  echo $new_name;
  </code></pre>
  
  <p>This works, but I was wondering if there was any easier/shorter way of applying the same logic? Like a regex maybe?</p>