Niixie Posted March 28, 2011 Share Posted March 28, 2011 Hey all, i need a function or a way to replace each letter in a string to a star (*) Thanks Quote Link to comment Share on other sites More sharing options...
jggretton Posted March 28, 2011 Share Posted March 28, 2011 The code below would do the trick: $string = "testing123"; $output = preg_replace('/./', '*', $string); print $output; Quote Link to comment Share on other sites More sharing options...
cssfreakie Posted March 28, 2011 Share Posted March 28, 2011 the above will work if you were looking for the stuff you see on password fields, have a read here: http://dev.w3.org/html5/markup/input.password.html Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted March 28, 2011 Share Posted March 28, 2011 the preg_replace method is very slow and processor intensive, you probably just want a combination of strlen and str_repeat. That is, only if cssfreakie's solution isn't what you actually need. -Dan Quote Link to comment Share on other sites More sharing options...
Niixie Posted March 30, 2011 Author Share Posted March 30, 2011 Cssfreakie works good for now, thanks Quote Link to comment Share on other sites More sharing options...
cssfreakie Posted March 30, 2011 Share Posted March 30, 2011 Cssfreakie works good for now, thanks No problem I was already wondering what would you do with the data if all characters are transformed (since you can't change it back) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.