lundi 12 janvier 2015

php how to use an array to simplify code

I have the following piece of php code:



<?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';}?>


Essentially saying, if typography setting is small echo 12, standard - echo 13, big - echo 14, huge - echo 15.


I know this code works fine, but I'm wanting to learn about using arrays and I'm wondering if this code can be simplified by using an array?


Aucun commentaire:

Enregistrer un commentaire