Remove the display Array[0]==>

Blockquote
$d = dir(“.”);
$dd = array();
while (false !== ($entry = $d->read())) {
if(‘.’ !== $entry && ‘…’ !== $entry) {
if( is_dir($entry)){
$dd[ ]= $entry;
}
}
}
$d->close();
print_r($dd);

The code above produces the result below.

Blockquote
Array ( [0] => dir1 [1] => dir2 )

I like to produce my target result below, dir names only.

Blockquote
dir1 dir2

and I like to use “echo” instead of “print_r” with your help.

foreach

or implode

Blockquote foreach or implode

Thank you, m_hutley.

Take a look at PHP glob(…); because it gives similar results to dir(…); and eliminates the tests for “.” and “…”

http://php.net/manual/en/function.glob.php

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.