Gracias por responder dedydamy...
Sin embargo en mi ejemplo el 'end' o el 'current' no funcionan y me generan un error:
Código HTML:
Ver originalwarning: end() [function.end]: Passed variable is not an array or object
Pues no toma el '$total' como un array (?)