scandir函數_PHP scandir()函數與示例

scandir函數

PHP scandir()函數 (PHP scandir() function)

The full form of scandir is "Scan Directory", the function scandir() is used to get the list of the files and directories available in the specified directory.

scandir的完整格式為“ Scan Directory”函數scandir()用于獲取指定目錄中可用的文件和目錄的列表。

Syntax:

句法:

    scandir(directory, sorting_order, context);

Parameter(s):

參數:

  • directory – It specifies the directory name (or path) from there we have to get the list of the files and directories

    directory –它指定目錄名稱(或路徑),從那里我們必須獲取文件和目錄的列表

  • sorting – It is an optional parameter; its default value is o (alphabetically sorting order). 1 can be used to descending order.

    排序 –這是一個可選參數; 其默認值為o(按字母順序排序)。 1可用于降序。

  • context – It is an optional parameter; it is used to specify the context (a set of options that can modify the behavior of the stream) to the directory handle.

    上下文 –它是一個可選參數; 它用于指定目錄句柄的上下文(一組可以修改流行為的選項)。

Return value:

返回值:

It returns an array of the files and directories, returns "False" on function execution failure.

它返回文件和目錄的數組,函數執行失敗時返回“ False”。

Example: PHP code to get and print the list of files and directories of a given directory

示例:獲取和打印給定目錄的文件和目錄列表PHP代碼

<?php
//directory name
$path = "/home";
//assigning the return array in $arr1
//defualt in ascending order
$arr1 = scandir($path);
//assigning the return array in $arr2
//Using 1 for descending order
$arr2 = scandir($path,1);
//printing the results
print_r($arr1);
print_r($arr2);
?>

Output

輸出量

Array
(
[0] => .
[1] => ..
[2] => folder1
[3] => folder2
[4] => folder3
[5] => main.php
)
Array
(
[0] => main.php
[1] => folder3
[2] => folder2
[3] => folder1
[4] => ..
[5] => .
)

翻譯自: https://www.includehelp.com/php/scandir-function-with-example.aspx

scandir函數

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/540897.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/540897.shtml
英文地址,請注明出處:http://en.pswp.cn/news/540897.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

韓順平.2011最新版.玩轉oracle視頻教程筆記,韓順平.2011最新版.玩轉oracle視頻教程(筆記)...

韓順平.2011最新版.玩轉oracle視頻教程ORA-01045: user XIAOMING lacks CREATE SESSION privilege; logon denied 警告: 您不再連接到 ORACLE。 SQL> show user; USER 為 ""SQL> conn system/p; 已連接。SQL> grant connect to xiaoming; 授權成功。SQL>…

方冪序列 c+~+_C ++編程中的Trigraph序列

方冪序列 c&#xff5e;Trigraph Sequences in C are the set of three characters starting from double question marks (??). These set of the characters replaces by a single character specified in the below table, C 中的Trigraph序列是從雙問號( ?? )開始的三個…

oracle sysauth,sysauth$基表的用戶權限的一點分析

select privilege#,level from sysauth$ connect by grantee#prior privilege# and privilege#>0 start with grantee#:1 and privilege#>0如上的sql語句頻繁執行&#xff0c;其實對于遞歸sql對于自己初始oracle才一年的菜鳥一般是略去不看的&#xff0c;eygle前輩們有時…

ansys 內聚力_內聚力 軟件工程

ansys 內聚力凝聚 (Cohesion) In general terms, the word cohesion means the action or act of forming a united whole. According to the definition of Cambridge University, cohesion is defined as "the state of sticking together, or being in close agreement…

oracle認證都需要考哪幾個方面,Oracle OCP認證要通過哪些考試

Oracle OCP認證要通過哪些考試Oracle OCP DBA認證是所有Oracle認證中最普及的一種認證&#xff0c;這一認證過程是專為那些想要從事Oracle管理的專業數據庫管理人員設計的&#xff0c;適用于Oracle9I DBAs的OCP認證通過改進&#xff0c;刪除了備份和恢復以及網絡考試&#xff0…

左側固定 右側自適應三種方法

第一種&#xff1a;float 單一層浮動法 例如&#xff1a;左側固定成100px; 則核心代碼 左側&#xff1a;width:100px;float:left; 右側 width:auto;margin-left:100px; 實例&#xff1a; <!DOCTYPE html> <html> <head> <meta charset"utf-8&q…

ruby 集合 分組_在Ruby中打印集合的元素

ruby 集合 分組We have gone through the implementation of sets in Ruby. They are very similar to arrays. Now, let us see how we print the elements present in a set. There are no indexes present in the sets because sets are used to store the large elements. …

linux下tmp目錄屬性,Linux:文件夾屬性及umask

回顧&#xff1a;文件在小&#xff0c;也要占用一個Block如&#xff1a;echo > a1.logls a1.log(文件大小為1k)du a1.log(文件大小也應該為1k&#xff0c;如果不是1k&#xff0c;可能selinux是打開的)du -s a1.log文件夾的權限&#xff0c;系統中的文件夾默認權限基本上都為…

python淺復制與深復制_Python中的淺復制與深復制

python淺復制與深復制In python, the assignment operator does not copy the objects, instead, they create bindings between an object and the target. The object, if a collection that is mutable or consists of mutable items uses the copy so that one can change …

邏輯回歸 數據_數據科學中的邏輯回歸

邏輯回歸 數據邏輯回歸 (Logistic Regression) Logistic regression is an applied mathematics analysis methodology accustomed to predict a data price supported previous observations of a data set. Logistic regression has become a very important tool within the…

Dede?刪除文檔同時文章中的圖片的方法

首先,在"/include"目錄下建立"extend.func.php"文件. 然后,將以下內容保存在"extend.func.php"文件中,一共三個函數&#xff1a;//解析body數據&#xff0c;獲得所有圖片的絕對地址function GetPicsTruePath($body,$litpic){$delfiles array();…

《linux操作系統》第06章在線測試,Linux系統管理一測試題-附答案.doc

Linux系統管理一測試題-附答案Linux系統管理一測試題姓名&#xff1a;班級&#xff1a;考試時間180分鐘,ls,ifconfig,hostname,cd的程序文件在哪里which mkdir ls ifconfig hostname cd查看當前的PATH變量的值echo $PATH在根下新建一個目錄study&#xff0c;在study目錄下建子目…

java8-02-Stream-API

[TOC] 0 Stream簡介 家庭住址 &#xff1a;java.util.stream.Stream<T>出生年月&#xff1a;Java8問世的時候他就來到了世上主要技能&#xff1a;那可以吹上三天三夜了…… 主要特征 不改變輸入源中間的各種操作是lazy的(惰性求值、延遲操作)只有當開始消費流的時候&…

跟隨者數字解碼_跟隨模式的數字

跟隨者數字解碼Problem statement: 問題陳述&#xff1a; Given a pattern containing only Is and Ds. I stands for increasing and D for decreasing. Devise an algorithm to print the minimum number following that pattern. Digits are from 1-9 and digits cant repe…

Linux內核機器ID,linux-如何強制內核重新讀取/重新初始化PCI設備ID?

我的機器(正在運行Linux內核3.2.38的計算機)在引導時具有錯誤的PCI設備的子系統ID(子設備和子供應商ID).如果我然后在系統仍處于啟動狀態(即熱插拔)時物理地拔出PCI設備并重新插入,則它將獲得正確的ID.請注意,錯誤的子設備ID和子供應商ID與設備的設備ID和供應商ID相同(請參見下…

Android ImageButton示例代碼

1) XML File: activity_main 1)XML文件&#xff1a;activity_main <?xml version"1.0" encoding"utf-8"?><android.support.constraint.ConstraintLayout xmlns:android"http://schemas.android.com/apk/res/android"xmlns:app"…

IIS 偽靜態下 利用PHP獲取 網址后綴

$_SERVER[HTTP_X_ORIGINAL_URL];轉載于:https://www.cnblogs.com/paddygege/p/7238228.html

kotlin 小數位數_Kotlin程序生成4位數OTP

kotlin 小數位數OTP stands for "One Time Password" is a 4-8 digit alphanumeric code which is sent to the user via email or phone number for validation. As the name suggests, it can be used once only. OTP代表“ 一次密碼”&#xff0c;它是4-8位的字母…

NestedScrolling機制

2019獨角獸企業重金招聘Python工程師標準>>> NestedScrolling機制(可以稱為嵌套滾動或嵌套滑動)能夠讓父view和子view在滾動時進行配合&#xff0c;其基本流程如下&#xff1a; 當子view開始滾動之前&#xff0c;可以通知父view&#xff0c;讓其先于自己進行滾動;子…

linux重定向命令是干嘛的,Linux系統下重定向命令應用及其語法有什么?

1。 標準輸入的控制語法&#xff1a;命令 文件將命令的執行結果送至指定的文件中。例如&#xff1a;ls -l > list 將執行“ls -l” 命令的結果寫入文件list 中。語法&#xff1a;命令>&#xff01; 文件將命令的執行結果送至指定的文件中&#xff0c;若文件已經存在&…