progress on problem 6 in php