Re: Replace credit card numbers with X ???

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux