I have a section of code that is used throughout my site. If a variable is set to true, I want to run a for loop around some code to group the items in categories. If it's false, I want the for loop to be completely ignored and just list all the items without any categories so the code inside should only run once.
This is throwing an error and I was wondering how to accomplish what I've described?
<?php
$group_by_categories = false;
if ($group_by_categories) {
for ($x = 0; $x <= 10; $x++) {
}
// run this code
if ($group_by_categories) {
}
}
?>
Aucun commentaire:
Enregistrer un commentaire