I have a for loop which I would only like to run in a certain condition. I now have duplicate information in my script. See below:
if ($condition == 1){
for ($number = 1; $number<=($total); $number++) {
echo $number; // Gives a complete list of numbers.
// List of queries/variables I use.
} else {
echo $number; // Only give one number in a certain condition.
// List of queries/variables I use which are exactly the same.
}
}
How can I make this more compact and get rid of the duplicates?
Aucun commentaire:
Enregistrer un commentaire