jebaraj Posted January 23, 2012 Share Posted January 23, 2012 I need to display Credit card number with only last 4 digits visible.The remaining numbers should display as ** eg: If the credit card number is 2222 1111 3333 4444 its should display as **** **** **** 4444 in a textbox Can anybody provide me a solution Quote Link to comment https://forums.phpfreaks.com/topic/255586-mask-credit-card-information-in-text-box/ Share on other sites More sharing options...
cyberRobot Posted January 23, 2012 Share Posted January 23, 2012 If you're looking to hide the number after it's been entered and submitted, you could use something like this: <?php $ccNum = "2222 1111 3333 4444"; print "<div>$ccNum</div>"; $ccNum_lastFour = substr($ccNum, -4); $ccNum = preg_replace("~\d~", '*', $ccNum); $ccNum = substr($ccNum, 0, -4) . $ccNum_lastFour; print "<div>$ccNum</div>"; ?> If you're looking to hide the credit card as it's being typed into the form, you'll need to look into solution using a client-side option like JavaScript. Quote Link to comment https://forums.phpfreaks.com/topic/255586-mask-credit-card-information-in-text-box/#findComment-1310301 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.