jeudi 18 août 2016

multiple if and elseif statements in PHP

in this case i have 69 category item and i wanted to store each of the item by the category. so, my "IF and ELSEIF" statements will looks like this

    if(category == 1){
       echo "1";
    } 
    elseif(category == 2){
       echo "2";
    }
    elseif(category == 3){
       echo "3";
    }
    elseif(category == 4){
       echo "4";
    }

if i am keep with these way, this will takes lots of time. So is there any simple way to do this? Thank you

Aucun commentaire:

Enregistrer un commentaire