Created
October 29, 2011 04:17
-
-
Save nileshk/1324066 to your computer and use it in GitHub Desktop.
JSON list of images in current directory
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 | |
/* | |
JSON list of all images files in current directory | |
*/ | |
$dir = "."; | |
$dh = opendir($dir); | |
$image_files = array(); | |
while (($file = readdir($dh)) !== false) { | |
$match = preg_match("/.*\.(jpg|png|gif|jpeg|bmp)/", $file); | |
if ($match) { | |
$image_files []= $file; | |
} | |
} | |
echo json_encode($image_files); | |
closedir($dh); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how to convert all image from dir to base64 list in json format