Php 按时间排序数组中的数据
为什么我会收到一个错误,指出$image不是数组?我还希望能够对$image中的图片/文件进行排序。我想在上传时对它们进行排序。首先上传到我的页面的顶部。这两个问题一直困扰着我Php 按时间排序数组中的数据,php,html,arrays,Php,Html,Arrays,为什么我会收到一个错误,指出$image不是数组?我还希望能够对$image中的图片/文件进行排序。我想在上传时对它们进行排序。首先上传到我的页面的顶部。这两个问题一直困扰着我 $files = glob("Pictures/*.*"); for ($i=0; $i<count($files); $i++) { $image = $files[$i]; sort($image); $supported_file = array( 'gif',
$files = glob("Pictures/*.*");
for ($i=0; $i<count($files); $i++)
{
$image = $files[$i];
sort($image);
$supported_file = array(
'gif',
'jpg',
'jpeg',
'png'
);
$ext = strtolower(pathinfo($image, PATHINFO_EXTENSION));
if (in_array($ext, $supported_file)) {
echo basename($image)."<br />";
echo '<img src="'.$image .'" alt="Random image" height="150" />';
echo '<div class="content_wrapp">
$files=glob(“Pictures/*.*);
对于($i=0;$i您应该对$files
进行排序,而不是对$image
进行排序。使用带有比较文件时间的函数的usort
$files = glob("Pictures/*.*");
usort($files, function($a, $b) { return filemtime($b) - filemtime($a); });
及及