Finished PHP conversion