santanudas
Technical User
Hi people,
I'm a complete newbie in this php world and was trying a very simple thing to start with. But can't see that I'm doing quite well. These are the things I'm trying to do:
list the directory content using UNIX “ls” command
split the out put
put the values in an array
display the result.
And I came up with something like this:
But it's not working. I think the splitting and putting into an array parts are not working. Any help from any one is very much appreciated.
I'm a complete newbie in this php world and was trying a very simple thing to start with. But can't see that I'm doing quite well. These are the things I'm trying to do:
list the directory content using UNIX “ls” command
split the out put
put the values in an array
display the result.
And I came up with something like this:
Code:
<?php
$this_dir = "images";
$dir_path = "/project/web/$this_dir";
$LS = "/bin/ls";
$CMD=$LS . " " . $dir_path . "/thumbs";
$thumbs = exec($CMD);
$qp = preg_split('/\n/', $thumbs);
$qq = array($qp);
$COL = count($qq);
echo ("Number of elements in the array: $COL <br><br>\n");
for($qx = 1; $qx<=$COL; ++$qx) {
$px = $qx-1;
echo ( "$qx) $thumbs[$px] <br>\n" );
}
?>