Snooble Posted February 1, 2007 Share Posted February 1, 2007 I have the user's phone number in a database i know how to echo the phone number to the user but i want to replace the first "however many" digits with *'s. Like they do with credit cards etc. Anyone know? Snooble Quote Link to comment https://forums.phpfreaks.com/topic/36681-solved-ing-information/ Share on other sites More sharing options...
Balmung-San Posted February 1, 2007 Share Posted February 1, 2007 Try: substr_replace($phone, "*", 0, strlen($phone) - X) Where X is the number of digits you wish to show. Also, if it's seperated by anything this will replace those characters. However, if it's universally seperated you can substr_replace each area. For a number like (123) 456-7890 to show only last 4: substr_replace($phone, "*", 1, 3) substr_replace($phone, "*", 6, 3) This will show: (***) ***-7890 At least it should. <.< Quote Link to comment https://forums.phpfreaks.com/topic/36681-solved-ing-information/#findComment-174886 Share on other sites More sharing options...
Snooble Posted February 2, 2007 Author Share Posted February 2, 2007 i dont get anything outputted to the browser?!? Do i need to echo something special? Thanks, Snooble Quote Link to comment https://forums.phpfreaks.com/topic/36681-solved-ing-information/#findComment-175457 Share on other sites More sharing options...
HuggieBear Posted February 2, 2007 Share Posted February 2, 2007 Yeah, are the numbers all in the same format? e.g (12345) 123456 or something similar? Regards Huggie Quote Link to comment https://forums.phpfreaks.com/topic/36681-solved-ing-information/#findComment-175484 Share on other sites More sharing options...
Snooble Posted February 2, 2007 Author Share Posted February 2, 2007 it's simply. 1234567890123456 for a credit card. I need to be able to show it as: ************3456 I'm storing the card number as: $list['CCNO'] and my current code which returns nothing is: substr_replace($list['CCNO'], "*", 0, strlen($list['CCNO']) - ; The page loads and everything but i get a blank space in place of the ccno. Thanks Hugs you genius lol, Snoobs Quote Link to comment https://forums.phpfreaks.com/topic/36681-solved-ing-information/#findComment-175490 Share on other sites More sharing options...
Ninjakreborn Posted February 2, 2007 Share Posted February 2, 2007 It has to be in an echo of some sort, or in a variable. Examples <?php // example 1 echo substr_replace($list['CCNO'], "*", 0, strlen($list['CCNO']) - ; // example 2 $temp = substr_replace($list['CCNO'], "*", 0, strlen($list['CCNO']) - ; echo $temp; ?> Quote Link to comment https://forums.phpfreaks.com/topic/36681-solved-ing-information/#findComment-175517 Share on other sites More sharing options...
Snooble Posted February 2, 2007 Author Share Posted February 2, 2007 lol. Yes you were right, i needed to echo the command, apologies. Thanks for your help! Quote Link to comment https://forums.phpfreaks.com/topic/36681-solved-ing-information/#findComment-175554 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.