Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to query the files in the directory by php

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail how php queries the files under the directory, Xiaobian thinks it is quite practical, so share it with you as a reference, I hope you can gain something after reading this article.

PHP query directory file method: 1, create a PHP sample file;2, get the parent directory of the current file;3, through the "scandir($con);" scan all files under the $con directory can be.

Operating environment: Windows 7 system, PHP7.1 version, DELL G3 computer

PHP Gets all files in the current directory

We sometimes want to get all the file names under the current directory, the following is a method I wrote, please refer to

//Get the parent directory of the current file $con = dirname(__FILE__);//Scan all files in the $con directory $filename = scandir($con);//Define an array to receive file names $conname = array();foreach($filename as $k=>$v){ //skip two special directories continue Jump out of the loop if($v==". " || $v==".. "){continue;} //truncate the file name, I only need the file name without suffix; then store it in the array. If you need a direct suffix $v then $conname[] = substr($v,0,strpos($v,". "));}

About "php how to query files under the directory" this article is shared here, I hope the above content can be of some help to everyone, so that you can learn more knowledge, if you think the article is good, please share it to let more people see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report