Actually, you could regale us with a tale of yore, I wouldn't mind.
I think the problem here is that the poster didn't want clarification; he wanted code.
I didn't give it to him, in line with the philosophy of most of the more active posters here. Occasionally we give code, more often just hints and advice. I'm kinda surprised that people interpret "here are the functions you need to complete this script" with "RTFM, noob!", but I'm still living by Weedpacket's old saying "give a man a fish..."
The fact that the OP now has working code is a testimony to the greatness of PHP and possibly his thought process also . If he'll run his typing through that process, that'd be even nicer 😉