Ya' row ze: Lets go!

You are here

Programmer challenge

I came across this code today in a drupal module. There is a very subtle bug in it. Can you spot it?

" class="dexp-bxslider">
<?php for($i = 0; $i < count($rows); $i+=$sliderows):?>

<?php for($j=$i; $j<$i+$sliderows; $j++):?>
<?php if(isset($rows[$j])) print $rows[$j];?>
<?php endfor;?>

<?php endfor;?>

Hint: what happens if count($rows) = 1 and $sliderows = 3? How would you rewrite this to not have the bug?

Back to top