Write a PHP Program to recursive traversals of directory.





Write a PHP Program to recursive traversals of directory.


<?php
/*
error_reporting (E_All |E_STRICT);
ini_set('display_errors',1);
*/
header('Content-Type: text/plain');

$dir=dirname(__FIlE__);

foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir))as $item)
{
          if($item->isFile()|| $item->isDir())
          {
                   echo $item.PHP_EOL;

          }
}

?>

OUTPUT:-

C:\xampp\htdocs\php practicle2020\.
C:\xampp\htdocs\php practicle2020\..
C:\xampp\htdocs\php practicle2020\practical10.php
C:\xampp\htdocs\php practicle2020\practical12.php
C:\xampp\htdocs\php practicle2020\practical2.php
C:\xampp\htdocs\php practicle2020\practical3.php
C:\xampp\htdocs\php practicle2020\practical4.php
C:\xampp\htdocs\php practicle2020\practical5.php
C:\xampp\htdocs\php practicle2020\practical6.php
C:\xampp\htdocs\php practicle2020\practicle1.php



Comments