Solved

Converting CC Info into a a new xxxx-xxx string

Posted on 2007-11-23
1
601 Views
Last Modified: 2008-02-01
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
Comment
Question by:jcbodyworks
1 Comment
 
LVL 20

Accepted Solution

by:
steelseth12 earned 500 total points
Comment Utility
$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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now