php - 如何让 PHP 查找包含某些内容的文件名

标签 php

我正在尝试这样做:

$filename = "/destination/destination2/file_*";

"* "= 任何内容

目标 2 文件:

file_somethingrandom

因为它 $filename 包含 * 所以它应该选择 file_somethingrandom

怎么做?

最佳答案

使用 glob()像这样的功能:

$filename = "/destination/destination2/file_*";
foreach (glob($filename) as $filefound)
{
    echo "$filefound size " . filesize($filefound) . "\n";
}

关于php - 如何让 PHP 查找包含某些内容的文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9943240/

相关文章:

php - Codeigniter:分组依据并从连接表中获取最新记录

php - 在 PHP 中将一种日期格式转换为另一种日期格式

php - PHP 中的 MongoDB - 如何将项目插入集合中的数组?

php - 在 Mysql 中选定的数据库中创建表时出错

php - 是否可以使用另一个连接中的列在另一个连接 mysql 中创建条件

php - 我想要密码中的一些特殊字符

php - 修改搜索功能以排除帖子并将结果限制为仅在前端每页 10 个

php - 当 WooCommerce 中的特定订单项元为空时发送自定义电子邮件

php - 创建登录脚本时遇到问题

PHP:if (!empty($array ["key"])) VS if (@$arr ["key"])。有什么区别吗?