I have a simple task to do with PHP, but since I’m not familiar with Regular Expression or something… I have no clue what I’m going to do.
what I want is very simple actually…
let’s say I have these variables :
$Email = 'john@example.com'; // output : ****@example.com
$Email2 = 'janedoe@example.com'; // output : *******@example.com
$Email3 = 'johndoe2012@example.com'; // output : ***********@example.com
$Phone = '0821212121'; // output : 082121**** << REPLACE LAST FOUR DIGIT WITH *
how to do this with PHP? thanks.
You’ll need a specific function for each. For mails:
For phone numbers
And see? Not a single regular expression used. These functions don’t check for validity though. You’ll need to determine what kind of string is what, and call the appropriate function.