I have an API that returns the brand of a credit card. I want to make them look nice for my user (e.g. correct case and spacing). The possible options are amex
, diners
, discover
, jcb
, mastercard
, unionpay
, visa
, or unknown
. Here's how I am currently doing it:
if ($x == "jcb") {
$x = strtoupper($x);
} elseif ($x == "amex"){
$x = "American Express";
} elseif ($x == "diners"){
$x = "Diners Club";
} elseif ($x == "unionpay"){
$x = "UnionPay";
} else {
$x = ucfirst($x);
}
Is there a more efficient way of doing this?