Please don't rely on this. For example of the extra detail that is really involved, see: http://en.wikipedia.org/wiki/List_of_Issuer_Identification_N... - e.g. 504837 is ATM only despite looking like a MasterCard. Card identification also occasionally changes - Diners was bought by MasterCard, Visa used to be 13 digits, etc. I'd be really wary of hard-coding this anywhere. If it passes the Luhn algorithm and the firs…
MasterCard didn't acquire Diners, it was just a partnership where Diners cards were branded as MasterCard and processed through MasterCard's network. Later Discover acquired Diners, and now they're processed through Discover's network.
But fair point - brand prefixes occasionally change, and if you hardcode them they'll eventually become out of date.