I need to show current record status in human readable format.
In my database I have an int for this field, so record may have status 1, 2, 3, 4 e.t.c
I wrote some code to show current status to user:
<?php
// code to retrieve current status from DB
// ...
if ($status == '1') {
echo "Current status: Active";
}
if ($status == '2') {
echo "Current status: Pending";
}
if ($status == '3') {
echo "Current status: Inactive";
}
// etc..
?>
This code looks very ugly, but I can’t figure out how to refactor it to make it more effective and without infinite series of conditions.
Make an array: