added php implementation