In a surprise move, Philadelphia's top prosecutor has pleaded guilty to a corruption charge and agreed to resign.