Dear LP members,
I am trying to write a PHP script that will generate directory list using a command
- Code: Select all
<?php
$cmd="ls -la /sharing/ | awk '{ print $9}'";
$files = array();
exec($cmd, $files);
echo '<pre>';
print_r($files);
echo '</pre>';
?>
This code works almost fine for me except it gives output like this
Array
(
[0] =>
[1] => .
[2] => ..
[3] => Anti-ARP
[4] => Connection-Maker
[5] => SXE
[6] => cbts
[7] => dgb
[8] => diglinux.com.tar.gz
[9] => forum.sql
[10] => forum.tar.gz
[11] => games
[12] => islam
[13] => movies
[14] => rhel
[15] => softwares
[16] => songs
[17] => stage-show
[18] => videos
[19] => voi-vidios
)
Can anyone help me out in removing this ARRAY and the ARRAY numbers and "=>" sign. The output should only be the names of directories.
Looking for a positive and quick reply.


