gpt4 book ai didi

php foreach glob 多个扩展

转载 作者:行者123 更新时间:2023-12-02 07:29:14 24 4
gpt4 key购买 nike

必须有更好的方式来写这个:

<?php $imagecounter = "no";
foreach (glob("images/*.jpg") as $image) {
$imagecounter = "yes";
}
foreach (glob("images/*.png") as $image) {
$imagecounter = "yes";
}
foreach (glob("images/*.gif") as $image) {
$imagecounter = "yes";
}
if ($imagecounter == "yes"){Create gallery}?>

该文件夹可能也有不应创建图库的 zip 或 pdf 文件

最佳答案

if(glob("images/*.{jpg,png,gif}", GLOB_BRACE))
{
//create gallery
}

就是这样:)

关于php foreach glob 多个扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23969187/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com