Find if a key exists in association list

I spotted this on stackoverflow before here, so have answered there.