I had a piece of code not working as I intended.
The code was roughly like this:
foreach ($arrayOfIds as $iterId)
{
if ($iterId === $unchangingId)
{
// ...
}
}
The problem was that it was going into the if statement regardless of whether the IDs matched or not.
Then I noticed that my if statement was incorrectly declared, and actually looked like this:
if ($iterId === $unchangingId);
{
// ...
}
That single semi colon gave me so much grief.
Now, I know how/why I didn't get a compiler or runtime error because of the if ($iterId === $unchangingId);
but I never knew you could have code inside 2 curly braces like that, without anything else.
I want to learn more about this, and what it gets used for, if anyone could elaborate on it I'd be extremely grateful!