04.04.2016, 15:45
Quote:
Yes. I praise you for finding this out yourself. Got a tutorial in my sig (don't know which one) that's on this topic, as well.
Unrelated, but pro tip: you can put multiple conditions in the loop header itself. If the condition isn't met the loop stops. Whereas with a nested if the loop keeps on running until it's done, even if there's no more space to store data. So in this case you might write: PHP код:
|
PHP код:
for(new i = 0; i < MAX_BUILDINGS; i ++)
PHP код:
for(new i = 0, j = cache_get_row_count(); i < j && i < MAX_BUILDINGS; i ++)
However if I use the second one, the loop will run for as many rows that are returned by the query, so that if the query only returns 5 rows, the loop won't go around 45 times for nothing, which also works vice-versa with
PHP код:
&& i < MAX_BUILDINGS;