我有以下代码:
$imageDir = "uploads/";
$allowedTypes = array('png', 'jpg', 'jpeg', 'gif');
$dimg = opendir($imageDir);
$images = array();
while ($imgfile = readdir($dimg)) {
if (in_array(strtolower(substr($imgfile, -3)), $allowedTypes) || (in_array(strtolower(substr($imgfile, -4)), $allowedTypes))) {
$images[] = $imgfile;
}
}
基本上我还需要订购 $images 数组中的图像。例如我有 image-1.png, image-2.png, image-23.png, image-3.png ,我希望它们以正确的顺序存储在我的 $images 数组 (1, 2, 3, 23)不是 (1, 2, 23, 3)。