Skip to content

Instantly share code, notes, and snippets.

@donmhico
Created October 16, 2019 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donmhico/bb55a803e2c14ba709c1aecab8cb3510 to your computer and use it in GitHub Desktop.
Save donmhico/bb55a803e2c14ba709c1aecab8cb3510 to your computer and use it in GitHub Desktop.
<?php
function clear_email( array $contact ) {
$clean = [];
foreach ( $contact as $contact_key => $contact_value ) {
if ( is_array( $contact_value ) ) {
$clean[ $contact_key ] = clear_email( $contact_value );
}
elseif ( is_email( $contact_value ) ) {
$email_parts = explode( '@', $contact_value );
$clean[ $contact_key ] = implode( '@', [ '***', $email_parts[1] ] );
}
else {
$clean[ $contact_key ] = $contact_value;
}
}
return $clean;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment