Jump to content

The 'Dir' or 'ls' Command


Drezard

Recommended Posts

hey daniel looks to my like you are in search of something like this

 

<?
if ($handle = opendir('.')) //put here your own folder e.g. opendir('/home') also it needs to be abolute
{
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != "..")
{
echo "$file<br>";
}
}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/71144-the-dir-or-ls-command/#findComment-357785
Share on other sites

Hello,

 

Modify your code with following code block to get the required results.

<?php
$tempPath = "img/";

if ($handle = opendir($tempPath)) 
{ 
while (false !== ($file1 = readdir($handle))) 
{ 
	if ($file1 != "." && $file1 != "..") 
	{
		if(is_dir($tempPath."/".$file1))
		{
			echo $file1 . '<br>';
		}
        	} 
}
closedir($handle);
}
?>

 

Hope this will solve your issues.

Regards,

Link to comment
https://forums.phpfreaks.com/topic/71144-the-dir-or-ls-command/#findComment-357805
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.