PDA

View Full Version : PHP array


jbroder
12-09-1999, 03:42 PM
I am new to PHP, so here is a simple question.

I found the safe mode ls command in an earlier posting.
When I try to access it on the command line, it works
great. When I put it into a php script, I only get the
last file. Here is my script:
[nbsp][nbsp]$arr_do =[nbsp][nbsp]array(exec("/big/dom/PHP_bin/ls -l /big/dom/PHP_bin/ls /big/dom/xgu
itarwar/www")) ;

Which returns the name of the last file in the directory in a scalar variable (not a one set array). Clearly, I don't
know how to set up an array. But I am following the instructions in the only PHP book I could find (by David Medinets).

Please help...

Terra
12-09-1999, 04:29 PM
There is no need to call 'ls' to get a directory listing... ;)

Just use the internal functions for working with Directories:
http://www.php.net/manual/ref.dir.php3

:)

--
Terra
sysAdmin
FutureQuest

jbroder
12-09-1999, 04:34 PM
Thanks!

Justin
12-09-1999, 05:56 PM
On a side note - any of PHP's exec(), system(), and similar functions will in fact only return the last line - I have not found a way to get actual output from any command line function from PHP. In the manual it mentions that it will always return just the last line so you can check for success/failure.

This is why they provide so many internal functions - PHP can handle a good deal of things you might normally need a command line to do - but when you do run into one you need (whois, for example) it is a royal pain...

------------------
Justin Nelson
FutureQuest Support