Created
December 6, 2011 08:50
-
-
Save k-holy/1437431 to your computer and use it in GitHub Desktop.
IMAGETYPE定数と拡張子とmimeTypeの一覧を取得
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ワンライナーは挫折しました…。 | |
$imageTypes = array_fill_keys(array_filter(array_keys(get_defined_constants()), | |
function($name) { | |
return (strncmp('IMAGETYPE_', $name, 10) === 0); | |
} | |
), array()); | |
array_walk($imageTypes, function(&$item, $key, $supported) { | |
$imageType = constant($key); | |
$supported = (0 !== ($supported & $imageType)); | |
$item['constant' ] = $key; | |
$item['imageType'] = $imageType; | |
$item['supported'] = $supported; | |
$item['extension'] = image_type_to_extension($imageType, false); | |
$item['mimeType' ] = image_type_to_mime_type($imageType); | |
}, imagetypes()); | |
echo '<pre>'; | |
print_r($imageTypes); | |
echo '</pre>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment