Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/239.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php随机日期列表数组_Php_Arrays_List_Date_Random - Fatal编程技术网

php随机日期列表数组

php随机日期列表数组,php,arrays,list,date,random,Php,Arrays,List,Date,Random,我需要按日期列出一个数组,这是我到目前为止所拥有的,它吐出了图像名称并给出了一个随机日期: $images = glob('images/{*.jpg,*.gif,*.png}', GLOB_BRACE); foreach($images as $image) { $image = str_replace('images/','',$image); $date = date('Y-m-d', strtotime( '-'.mt_rand(0,1351).' days'));

我需要按日期列出一个数组,这是我到目前为止所拥有的,它吐出了图像名称并给出了一个随机日期:

$images = glob('images/{*.jpg,*.gif,*.png}', GLOB_BRACE);

foreach($images as $image) 
 {
  $image  = str_replace('images/','',$image);
  $date   = date('Y-m-d', strtotime( '-'.mt_rand(0,1351).' days'));
  $result = $image . '<br />' . $date . '<br /><br />';

echo $result;

}
现在我只需要按日期列出它的帮助…一如既往地感谢任何帮助。

$images=glob('images/{*.jpg,*.gif,*.png}',glob_BRACE);
$images = glob('images/{*.jpg,*.gif,*.png}', GLOB_BRACE);

$sorted = array();
foreach($images as $image) 
{
  $image  = str_replace('images/','',$image);
  $timestamp   = strtotime('-'.mt_rand(0,1351).' days');
  $sorted[$timestamp] = $image;
}

ksort($sorted);

foreach ( $sorted as $timestamp => $image )
{
  $date = date('Y-m-d', $timestamp);
  $result = $image . '<br />' . $date . '<br /><br />';
  echo $result;
}
$sorted=array(); foreach($images作为$image) { $image=str_replace('images/','','$image); $timestamp=strottime('-'.mt_rand(01351)。'days'); $sorted[$timestamp]=$image; } k分拣(已分拣); foreach($排序为$timestamp=>$image) { $date=日期('Y-m-d',$timestamp); $result=$image.'
'.$date.'

'; 回声$结果; }
$images=glob('images/{*.jpg、*.gif、*.png}',glob_括号);
$sorted=array();
foreach($images作为$image)
{
$image=str_replace('images/','','$image);
$timestamp=strottime('-'.mt_rand(01351)。'days');
$sorted[$timestamp]=$image;
}
k分拣(已分拣);
foreach($排序为$timestamp=>$image)
{
$date=日期('Y-m-d',$timestamp);
$result=$image.'
'.$date.'

'; 回声$结果; }
创建一个图像数组,使用日期作为键,然后在输出前对键进行排序

$images_arr = array();
foreach($images as $image)
{
  $date   = date('Y-m-d', strtotime( '-'.mt_rand(0,1351).' days'));
  $images_arr[$date] = str_replace('images/','',$image);
}
// Sort on array keys
ksort($images_arr);

// Output your array however you need to
foreach($images_arr as $img)
{
  // output
}

创建一个图像数组,使用日期作为键,然后在输出之前对键进行排序

$images_arr = array();
foreach($images as $image)
{
  $date   = date('Y-m-d', strtotime( '-'.mt_rand(0,1351).' days'));
  $images_arr[$date] = str_replace('images/','',$image);
}
// Sort on array keys
ksort($images_arr);

// Output your array however you need to
foreach($images_arr as $img)
{
  // output
}

您希望您的输出结果如何?你能举个例子吗?你希望你的输出是怎样的?你能举个例子吗?该死的,我打字太慢了,hsz打败了我,找到了同样的解决办法:)迈克尔,这总是发生在我身上(可恶,我打字太慢了,hsz比我想出了同样的解决办法:)迈克尔,这总是发生在我身上(因为我更好地理解了这个问题,所以选择了这个问题,但要感谢所有的回答:)因为我更好地理解了这个问题,所以选择了这个问题,但要感谢所有的回答:)