我是 php 新手,想探索如何以不同的方式实现相同的目标。我有以下工作代码,并希望看到更好的编码方式。任何建议表示赞赏。
<?php
$districts = "Aizawl";
$fc = "First City";
$sc = "Second City";
$tc = "Third City";
if ($districts == "Aizawl") {
$city = $fc;
} elseif ($districts == "Lunglei") {
$city = $sc;
} elseif ($districts == "Saiha") {
$city = $tc;
}
?>
<?php
echo $city;
?>