簡體   English   中英

全局 function。 查找所有帶有 name.extension 的文件

[英]glob function. Find all file with name.extension

查找所有帶有 name.extension 的文件?

   $file = null;
   $file = glob('*/*/media/name.*');
   rsort($file);
   echo'<pre>'; print_r($file); echo'</pre>';
   echo $file[0].'<br>';
   echo $file_ext = pathinfo($file[0], PATHINFO_EXTENSION);

您需要使用Glob function

$name= "hello";

$files = glob("/path/to/files/$name.*"); // Will find all file with hello.extension

if (count($files) > 0){
foreach ($files as $file)
 {
    $info = pathinfo($file);
    echo "File found: extension ".$info["extension"]."<br>";
 }
 }else{
  echo "No file name exists called $name."
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM