Replace all characters of string to asterisks except first and last characters in PHP -
this question has answer here:
- how replace characters asterisks 4 answers
how replace characters of string asterisks except first , last characters in php?
for example test should become t**t , profanity become p******y , on
function get_starred($str) { $len = strlen($str); return substr($str, 0, 1).str_repeat('*', $len - 2).substr($str, $len - 1, 1); } $mystr = 'yourname'; echo get_starred($mystr); //should show y******e
Comments
Post a Comment