monkeytooth Posted November 20, 2008 Share Posted November 20, 2008 What I am thinking is something to the effect of when you sign up for something and use your credit card it blanks out all but the last 3 or 4 digits.. I know i can do something with str_repeat and strlen.. but breaking it apart to the last 3 or 4 is that part thats getting me. Right now im stuck with all or none.. Im not working with cards just for refrence, and the strings can be 8 to 25 char long so im looking for something that i can make it ****** the first 5 to 22 chars then display the last 3.. any ideas? Link to comment https://forums.phpfreaks.com/topic/133516-solved-hiding-part-of-a-string-how-to/ Share on other sites More sharing options...
monkeytooth Posted November 20, 2008 Author Share Posted November 20, 2008 nevermind.. a little more research and playin around and I found my own answer i think.. Link to comment https://forums.phpfreaks.com/topic/133516-solved-hiding-part-of-a-string-how-to/#findComment-694446 Share on other sites More sharing options...
gevans Posted November 20, 2008 Share Posted November 20, 2008 <?php $number = 123456789; $number_length = strlen($number)-5; $replace = NULL; for($i=0;$i<=$number_length;$i++){ $replace .= '*'; } $result = substr_replace($number, $replace, 0, $number_length); echo $result; //should print *****6789 ?> Haven't checked it, but should work Link to comment https://forums.phpfreaks.com/topic/133516-solved-hiding-part-of-a-string-how-to/#findComment-694449 Share on other sites More sharing options...
monkeytooth Posted November 20, 2008 Author Share Posted November 20, 2008 thanks, that actually may work better then what i made up Link to comment https://forums.phpfreaks.com/topic/133516-solved-hiding-part-of-a-string-how-to/#findComment-694469 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.