you first populate an array then run through and print from it Look again: the OP is indeed --unnecessarily-- populating an array, but he is not looping through it. He indexes into the array in the push.
CountZero A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
| [reply] [d/l] |
Sorry - obviously didn't make myself clear. I meant looping through the @refnos array (with foreach) to print, not looping through the @data array; in the example, the @refnos array is superfluous although it is probably doing more in the whole application - or at least I hope it is.
I wasn't actually aware - or had forgotten - that split could be limited like your CountZero's example. Every day I learn something (or am reminded of it) is a day not wasted. Or something.
| [reply] |