Tracks
/
PHP
PHP
/
Exercises
/
Mask Credit Card
Mask Credit Card

Mask Credit Card

Easy

Instructions

Create a function maskify to mask digits of a credit card number with #.

Requirements:

  • Do not mask the first digit and the last four digits
  • Do not mask non-digit chars
  • Do not mask if the input is less than 6
  • Return '' when input is empty

Examples:

  • 1234-5678-9012 converts to 1###-####-9012
  • 123456789012 converts to 1#######9012
Edit via GitHub The link opens in a new window or tab
PHP Exercism

Ready to start Mask Credit Card?

Sign up to Exercism to learn and master PHP with 11 concepts, 115 exercises, and real human mentoring, all for free.