I took a data mining course during my third year - here's an implementation of the (k-)nearest neighbour algorithm in PHP.