$ext_arr = array( 'image' => array('gif', 'jpg', 'jpeg', 'png','tiff'), 'media' => array('swf', 'flv', 'mp3', 'wav', 'wma', 'wmv', 'mid', 'avi', 'mpg', 'asf', 'rm', 'rmvb'), 'file' => array('doc', 'docx', 'xls', 'xlsx', 'ppt', 'txt', 'zip', 'rar', 'gz', 'bz2'), );
This is a two-dimensional array, and how to get the values in one dimension based on the values in the two dimensions.
Like knowing how GIF gets the image. or according to the value provided MP3. can get media.
Reply content:
$ext_arr = array( 'image' => array('gif', 'jpg', 'jpeg', 'png','tiff'), 'media' => array('swf', 'flv', 'mp3', 'wav', 'wma', 'wmv', 'mid', 'avi', 'mpg', 'asf', 'rm', 'rmvb'), 'file' => array('doc', 'docx', 'xls', 'xlsx', 'ppt', 'txt', 'zip', 'rar', 'gz', 'bz2'), );
This is a two-dimensional array, and how to get the values in one dimension based on the values in the two dimensions.
Like knowing how GIF gets the image. or according to the value provided MP3. can get media.
echo in_array($extension,$ext_arr['image'])?'image':(in_array($extension,$ext_arr['media'])?'media':'file');
No way, can only traverse the upper layer of data in_array check. Otherwise, we'll build a mapping table.