PHP Get file name starting with prefix

前端 未结 3 1124
一个人的身影
一个人的身影 2021-01-07 19:10

This is a custom function. At the moment, this function get all the file in the default directory, strip \".php\" and list them.

The problem is that I want to only

3条回答
  •  梦谈多话
    2021-01-07 19:48

    I like another, simple way:

    1. get all files in folder

       $path = './images'; 
       $files = glob($path.'/*');
    

    2. get all files having extension .jpg

       $path = './images'; 
       $files = glob($path.'/*.jpg');
    

    3. get all files having prefix myprefix_

       $path = './images'; 
       $files = glob($path.'/myprefix_*');
    

提交回复
热议问题