Search
 
SCRIPT & CODE EXAMPLE
 

PHP

list all files in directory php

$path    = './';
$files = scandir($path);
$files = array_diff(scandir($path), array('.', '..'));
foreach($files as $file){
  echo "<a href='$file'>$file</a>";
}
Comment

php get all php files in a directory

foreach(glob('includes/*.php') as $file) {
    ...
}
Comment

php get list of filenames in diretory


<?php
// $dir is dir you want to return names of files and folders (first level - not recursive)
$dir    = '/tmp'; // './' for the root for the file calling scandir
$files1 = scandir($dir); // assending list
$files2 = scandir($dir, 1); //desending list 

print_r($files1);
print_r($files2); //frist files then folders alphabetically respective of types

//output $files1 order of folders then files alphabetically respective of types
//Array
// (
//    [0] => .
//    [1] => ..
//    [2] => folder1
//    [3] => folder2
//    [4] => folder3
//    [2] => file1
//    [2] => file2
//    [2] => file3
// )

?>

Comment

php list all files in directory

scandir ( string $directory [, int $sorting_order = SCANDIR_SORT_ASCENDING [, resource $context ]] ) : array
Comment

PREVIOUS NEXT
Code Example
Php :: how to install apache mysql php on ubuntu 18.04 
Php :: signup api in laravel 
Php :: php kommentar 
Php :: bind to class blade laravel 
Php :: php get html tags from string 
Php :: laravel get biggest id 
Php :: laravel bootstrap navbar active 
Php :: drop foreign key laravel eloquent 
Php :: Best Security tools for php 
Php :: database, counts,php, 
Php :: laravel generate unique string 
Php :: epoch to date php 
Php :: CHECKING IF FILE IS EMPTY IN PHP 
Php :: laravel array to string conversion 
Php :: laravel create resource 
Php :: compact laravel 
Php :: laravel get from model 
Php :: auto refresh extintion php 
Php :: laravel rate limit 
Php :: what is Laravel Eloquent ORM. 
Php :: laravel how to nested foreach 
Php :: compare two datetime php 
Php :: php header content type json 
Php :: @method overide form laravel 
Php :: get dates between two dates using specific interval using carbon 
Php :: PHP sha1 — Calculate the sha1 hash of a string 
Php :: php strip url of all invalid characters 
Php :: wordpress how to display breadcrumb in child theme programmatically 
Php :: validate file count with validate in laravel 
Php :: Calculate Math Expression From A String Text With PHP 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =