• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 648
  • Last Modified:

Converting CC Info into a a new xxxx-xxx string

I have a credit card number I grab from the database. I need to convert this string into a format where all digits become an x, except for the last four digits. any ideas how to do this? Thanks!
0
jcbodyworks
Asked:
jcbodyworks
1 Solution
 
steelseth12Commented:
$card = "4111111111114321";
      
      $card = "xxxxxxxxxxxx".substr($card,-4);

      print $card;
      
      ### OR ###
      
      
      $card = "4111-1111-1111-4321";
      
      $card = "xxxx-xxxx-xxxx-".substr($card,-4);

      print $card;
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now