Archive for Design and Usability

PHP: Making Credit Card Numbers Human-Readable

If you’ve ever tried to enter a 16 digit credit card number all in one blob, you’ll know it’s hard. To make life easier for the person responsible for processing online credit card orders, I needed to split up the credit card number and insert a space every 4 characters.

I’m not very schooled up on RegEx, and after spending ages searching for how to do it, I came across this:

<?php
echo implode(' ',str_split($credit_card_number,4));
?>

Hopefully it saves someone else some time!

Comments (1)

Use of “former” and “latter”

Does this bug anyone else?

Whilst reading up on IPsec at Wikipedia, I came across this:

IPsec is implemented by a set of cryptographic protocols for (1) securing packet flows and (2) internet key exchange. Of the former, there are two:

I want to learn about IPsec. I don’t want to be hindered by having to read back over the sentence to remind myself which was the former and which was the latter.

Would it be so hard to swap “Of the former, there are two:” with “For securing packet flows, there are two protocols:” ? I’d find that much easier to digest.

Comments

Use of “former” and “latter”

Does this bug anyone else?

Whilst reading up on IPsec at Wikipedia, I came across this:

IPsec is implemented by a set of cryptographic protocols for (1) securing packet flows and (2) internet key exchange. Of the former, there are two:

I want to learn about IPsec. I don’t want to be hindered by having to read back over the sentence to remind myself which was the former and which was the latter.

Would it be so hard to swap “Of the former, there are two:” with “For securing packet flows, there are two protocols:” ? I’d find that much easier to digest.

Comments