Re: how: Output of 'ls' as an array
| From: | Dan Kuykendall | Date: | Thu, 01 Jun 2000 16:14:36 +0000 |
| Subject: | Re: how: Output of 'ls' as an array | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-833@lists.php.net to get a copy of this message | ||
Hey, thanks for the code. It worked great!
As mentioned in a previous post, I cannot believe I did not see that in
the documentation.
Dan Kuykendall (aka: One who does not read the docs carefully)
Andrew White wrote:
>
> > How would I save the output of 'ls -l' as an array. I need to be able to
> > take each line and save it as an entry in an array for use later. Does
> > anyone know how this can be done?
>
> Use exec() and pass in an array as the second parameter. This gets filled
> with each line being a single item. e.g.
>
> <?php
>
> $path = "/home/httpd/html";
> $out = array();
> exec("ls -l $path", $out);
>
> echo "<pre>";
> for ($i = 0; $i < count($out); $i++) {
> echo $out[$i] . "\n";
> }
> echo "</pre>";
>
> ?>
>
> Andrew
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net