Last active
August 29, 2022 18:00
-
-
Save mishajib/43ad06262f1c755e3134aec24db0a151 to your computer and use it in GitHub Desktop.
This helper helps to remove email & phone number from string/text.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function removeEmailAndPhoneFromString($string) { | |
// remove email | |
$string = preg_replace('/([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)/', '*****', $string); | |
// remove phone | |
$string = preg_replace('/([0-9]+[\- ]?[0-9]+){4,}/', '*****', $string); | |
return $string; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment