For-loop inside if statement - possible?

Hi!
I’m working on a RFID project, where I’ve scan an RFID card, and saved its unique ID into an array.
I want the Arduino to recognize multiple RFID cards, so I’ve created some arrays to check what card have been scanned…

I got these arrays, and when I scan a card, the ID is stored into the UniqueID array.

byte keyChain[4] = {0x4D, 0x9A, 0xE2, 0xEA};
byte creditCard[4] = {0x25, 0x30, 0xFD, 0x2B};
byte UniqueID[4];

I’ve been using this to check what card have been scanned:

         if(UniqueID[0] == creditCard[0] && UniqueID[1] == creditCard[1] &&
                UniqueID[2] == creditCard[2] && UniqueID[3] == creditCard[3]) {
                Serial.println("");  
                Serial.println("Creditcard scanned!");
                Serial.println(" ");
                digitalWrite(14, HIGH);  
                delay(1000);
                }

As you can see this code is a bit hairy, and I want to make it smaller and more elegant if that’s possible.

I was thinking something like this, but I can’t figure how to get it to work! Is it possible to write it this way?

                if( for(int i = 0; i<4; i++) { creditCard[i] == UniqueID[i]; } )
                  { doSomeStuffHere(); }

Put the if inside the for loop, not the other way round

boolean matched = true;
for(int i = 0; i < 4; i++)
{
  if (creditCard[i] != UniqueID[i])
  {
    matched = false; 
  }
}
if (matched)
{
  //do stuff for a match 
}
else
{
  //do stuff for a mismatch 
}

You could also use a 2 dimensional array to hold several valid IDs and use 2 nested for loops. One for the ID and one for each element of the current ID.

You could just use memcmp() to compare the whole array in a single statement, and lose the for loop completely..

Yes, Basically I want to compare two arrays. I've never used memcmp() before. Is there a different syntax compared to c++?

Is there a different syntax compared to c++?

The Arduino IDE uses C++