Replace all characters of string to asterisks except first and last characters in PHP -


this question has answer here:

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

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -