I am trying to follow the code on the php docs listed here http://php.net/manual/en/function.scandir.php
However when I run the code nothing is displayed. Could someone please show me where I am making mistakes?
my code
<?php
$directory = "/xyz/images/";
$images = glob($directory . "*.jpg");
foreach($images as $image)
{
echo $image;
}
error_reporting(E_ALL);
?>
Nothing is being displayed. I am using xampp as on windows. I have also referenced these questions Listing all images in a directory using PHP
Get filenames of images in a directory
I have also tried "c:/xampp/htdocs/xyz/images/", " /xyz/images/" , "xyz/images/", "/images/"as my directory.
<?php
error_reporting(E_ALL);
$directory = scandir("linewalk');
$images = glob($directory . "*.jpg");
foreach($images as $image)
{
echo $image;
}
?>
its now throwing errors Parse error: syntax error, unexpected '.'
<?php
error_reporting(E_ALL);
foreach (scandir(".") as $file)
echo $file . "\n";
?>
****** thanks for all your help and suggestions*********
works and lists content of current dir
I am currently in root/xyz/test
so to scan /xyz/images it should be
(scandir("qa/linewalk")
Warning: scandir(qa/linewalk,qa/linewalk): The system cannot find the path specified - is what I get when I try