Can this just be changed to:

```php
for ($i = 0, $c = max(0, $total); $i < $c; $i++) {
    // ...
}
```