Log in

View Full Version : Resolved shorthand if/else



ggalan
06-06-2011, 12:40 PM
how would i write this in shorthand?


<?$i = 0;?>
foreach($datas as $row){
?>
<ul class="title<? if($i % 0 {echo "0"; }else {echo "1"})?>">
<li></li>
</ul>
<? $i+=1;}?>


something like this?

$i % 0 ? echo"0" : echo"1"

JoeDaStudd
06-06-2011, 01:30 PM
Your very close.

This will work.

echo ($i%0)?"0":"1";