Which would be more optimal of the two? I can't test it on my computer, I can't rely on it.
foreach($links as $link){
if($a){
//do something
}
if($b){
//do something
}
if($c){
//do something
}
if($d){
//do something
}
}
OR:
if($a){
foreach($links as $link){
//do something
}
}
if($b){
foreach($links as $link){
//do something
}
}
if($c){
foreach($links as $link){
//do something
}
}
if($d){
foreach($links as $link){
//do something
}
}
I think The first one is better. Let’s say
$a === trueand$b === true. In the first example only one loop will be executed, but on the second example the same loop will be executed twice.