added php version of the script