Show Directory list in php but only .csv files

PedroMart2020 :

I need to show the files in the directory with php but right now I have this (which shows everything):

<?php
$d = dir(getcwd());

echo "Handle: " . $d->handle . "<br>";
echo "Path: " . $d->path . "<br>";

while (($file = $d->read()) !== false){
  echo "filename: " . $file . "<br>";
}
$d->close();
?>

How can I do so that I just get the list of .csv files in the directory...I don't want it to show anything else.

How can I do this?

Pierre :

To do this, you may use glob function, which accepts a file mask : https://www.php.net/manual/en/function.glob.php

$files = glob('*.csv');

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=404694&siteId=1