Solved

Converting CC Info into a a new xxxx-xxx string

Posted on 2007-11-23
1
610 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
ID: 20341490
$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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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…

679 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