That would take nested for loops, where each number was put through all of it's ... So you should try to take everything that doesn't change out of the loop.
php.net