用陣列array去當作if多重判斷式

if( x ==jpg || x==gif || x==png)//這樣很多會出錯並且很煩

嘗試 array去當作if多重判斷式 這樣用法

$HappyArray = array(
“jpg" => “jpg",
“JPG" => “JPG",
“gif" => “gif",
“GIF" => “GIF"
);
if(isset($HappyArray[‘avi’])){
echo $HappyArray[“avi"];
}else {
echo ‘is null’;
}