【发布时间】:2015-01-12 12:16:09
【问题描述】:
我有以下一段 php 代码:
<?php
if(get_theme_mod('typography_setting')=='small')
{
echo '12';
}
else if(get_theme_mod('typography_setting')=='standard')
{
echo '13';
}
else if(get_theme_mod('typography_setting')=='big')
{
echo '14';
}
else if(get_theme_mod('typography_setting')=='huge')
{
echo '15';
}
?>
基本上说,如果排版设置是小回声 12,标准 - 回声 13,大 - 回声 14,巨大 - 回声 15。
我知道这段代码可以正常工作,但我想了解如何使用数组,我想知道这段代码是否可以通过使用数组来简化?
【问题讨论】:
-
根据你的情况应该是switch case
-
在那里使用 in_array()
标签: php arrays if-statement echo