php map reduce implementation