That's all that I wan't the code to do for now.
You want the code to just reset the Arduino twice? I'm at a loss to understand why.
Try separating the php stuff into two separate blocks - one to open the serial port and the other to close it.
Do you have debug mode turned on in PHP?