Is there anyway I can clean up
if($class == 2 AND $posts >=1){$showpost ="1";} else {$showpost ="$posts";
if($class == 3 AND $posts >=2){$showpost ="2";} else {$showpost ="$posts";
if($class == 4 AND $posts >=3){$showpost ="3";} else {$showpost ="$posts";
if($class == 5 AND $posts >=4){$showpost ="4";} else {$showpost ="$posts";
if($class == 6 AND $posts >=5){$showpost ="5";} else {$showpost ="$posts";
if($class == 7 AND $posts >=6){$showpost ="6";} else {$showpost ="$posts";
}}}}}}
As I don’t want }}}}}} at the end.
The
ifis split into two sections:This matches the logic in your original code – it’s just a matter of seeing the pattern.
If you need $showpost to be a string (chances are you don’t), you can cast to string like this: