file/directory operations in php

We can do numerous file directory operations in PHP. To delete a file “unlink” function is used. In below program, we can see different operations, we can uncomment code to see the behavior.

<!doctype html>
<meta charset="utf-8">
<title>Untitled Document</title>


$dir = "tasks/";

// to delete a single file

// to show all the text files in a directory
  foreach (glob($dir."*.txt") as $filename)
  echo $filename . "<br>";

// to delete all the files from a directory
$dir = "files/";

foreach(glob($dir."*.*") as $v)





Add a Comment

Your email address will not be published. Required fields are marked *