You could use regular expressions:
$type='gif';
if (preg_match("/(gif|jpg|peg|png|.js)$/", $type))
{
echo 'match';
}
else
{
echo 'no match';
};
But note: the most condensed way is not neccessarily the clearest or fastest way.
Sometimes using a not-so-condensed method helps you to understand just what is going on. (sure it seems very clear now, but come back in two months time and see how clear it is then)