Re: Replace credit card numbers with X ???
| From: | Jochem Maas | Date: | Tue, 25 Jan 2005 16:18:30 +0000 |
| Subject: | Re: Replace credit card numbers with X ??? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-207242@lists.php.net to get a copy of this message | ||
Joe Harman wrote:
Hello, I need to replace all the numbers of a credit card except for the last 4 with an 'X' ... can't seem to locate the string function for this... can someone point me in the right direction here to what php item i should be using.that'll be: string php_replace_all_but_last_four_chars_of_creditcard_number(string input[, string pad_string]) actually that func doesn't exist - what you need to do (well its one way to do it) is use a combination of substr() and str_pad() e.g: echo str_pad(substr($cc, -4), 20, 'X', STR_PAD_LEFT); where $cc is the previously checked/verified/sanitized creditcard no. and 20 is the length of a creditcard no. - forgive me if I'm wrong about the CC number length, I don't have a creditcard.
Thanks! Joe