StaffCoder
PHP
PHPPHP 8
10 modules · 49 challengesSign up
Module 4 of 10 · 5 challenges

PHP Strings and Text

Learn how to format money and aligned columns, parse delimited text, handle accented UTF-8 names with the mb_ functions, validate codes with regular expressions, and render a complete receipt from raw order lines.
Finish every challenge, or complete the star challenge, to complete the module.

Challenges

5 challenges

Shelf Price Labels

Sign up to unlock
—No data yeteasy
About this challenge

Shelf labels print raw cent amounts like 123450 with no decimal point or separators, quantities jump around, and the name and price columns on the label do not line up.

Solved in a browser IDE and graded by tests. Sign up to solve

Order Line Parsing

Sign up to unlock
—No data yeteasy
About this challenge

Order lines arrive from the till as pipe-separated text with stray spaces around every field and staff comment lines mixed in, so the order summary shows padded product names, treats notes as orders and cannot list the codes it received.

Solved in a browser IDE and graded by tests. Sign up to solve

Accented Product Names

Sign up to unlock
—No data yeteasy
About this challenge

Product names with accented letters come out too long in the name counter, lose half a letter when shortened for the label, are only partly upper-cased on the price board and end up one space short in the label column.

Solved in a browser IDE and graded by tests. Sign up to solve

SKU Pattern Checks

Sign up to unlock
—No data yeteasy
About this challenge

Mistyped product codes such as lowercase letters or an extra digit slip into orders, the shelf map needs the number inside each code, and names typed with several spaces between words break the label layout.

Solved in a browser IDE and graded by tests. Sign up to solve

Receipt Formatter

STAR
Solving it completes the module
—No data yeteasy
About this challenge

At the end of each order the till prints a plain-text receipt from the raw order text, but staff notes, mistyped codes, broken lines and long or accented product names make it unreadable and its columns drift.

Solved in a browser IDE and graded by tests. Sign up to solve

We use cookies that are necessary to run Staffcoder, and optional analytics cookies to see which pages get used. Analytics stays off unless you accept. Read our Cookie Policy.