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:
echo implode(' ',str_split($credit_card_number,4));
Hopefully it saves someone else some time!