I would like to show the customers credit card number on previous bookings that they have had, but only the last 4 digits of the card number, does anyone know how to do this, and make all the other numbers ****'s?
split the number into about 4 sections- and store them in non logical names to make it harder for hackers to find(you should be doing this if you are storing the number on your web server anyway- and if you don't own the server, I suggest you think twice about it)
then when you retreive the number use something like substr_replace() to replace the output to the browser with ***
Sometimes, when my code just won't behave, I take it outside and make it listen to britney spears music, and when it comes back it's really well behaved. I wonder if it's suffering from post tramatic stress syndrome now..
then whenever you do an echo, echo that variable instead.
And as long as the number has more than 4 digits it'll figure out the rest because it's using strlen() of the number, and just taking four less than that as the number of *'s to show... then it uses substr() to get the last 4 numbers.
substr(<which string>, <where to start>, <how many to get>)
So we're starting at -4, which is 4 from the end, and getting 4.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.