PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Hi, I have a simple while statement that grabs a list of categories from the database.
I wil be using AJAX to make the links functional, but basically I need to figure out an easy way for the last time the while loop runs it will not print out the pipe |
Is there an easy if statement I can put within the while loop?
if(last loop) { do this } else { run loop again }??
To optimize the code. If we can avoid running code over and over within a loop (more computer cycles), then you should do so. In a language like PHP this usually isn't a problem, but it is considered good practice.
I also find it much easier to debug an array than a bunch of strings, especially for a simple collection loop like yours. I.e. ability to manipulate the array and output much cleaner, var_export() for instance.