Foreach循环在输出上混洗[重复]

问题描述 投票:-4回答:1

这个问题在这里已有答案:

是否有一种简单的方法可以在每次页面加载时将输出的foreach循环结果混乱?

foreach(glob('images/fotoalbum/*.*') as $file)
php glob shuffle
1个回答
1
投票

你不能在输出之后洗牌,但你可以在之前。

试试这个

$dir=glob('images/fotoalbum/*.*');
shuffle($dir);
foreach($dir as $file){
//operation here
}
© www.soinside.com 2019 - 2024. All rights reserved.