Re: Chopping up a comand line return.

From: Date: Fri, 02 Feb 2001 15:23:20 +0000
Subject: Re: Chopping up a comand line return.
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-37850@lists.php.net to get a copy of this message
Try this : <?php $fp = popen ("/bin/ls ", "r"); while(!feof($fp)) {$buffer = fgets($fp,4096); echo "\n<br><li>&nbsp;<a href=".chr(34).$buffer.chr(34).">".$buffer."</a>";} pclose($fp) ?> s> Here is my problem, s> I want to read the contents of a dir, on a linux machine, in proper order s> according to date (ie. from newest to oldest). My problem is I know how to s> do it in perl....but not in php. I tried what I use is perl and it doesn't s> work. Here is what I have that does work. s> $stuff = ls -C1t /your/dir/to/read/from/$author/; ---works s> now I want to parse up $stuff to get the 10 or so files names so I can link s> to them. I just s> cannot figure out how to do it in php. s> This is how I would do it in perl/CGI s> @stuff = same as above s> foreach $filename (@stuff){ s> next if $filename !~ /(inc$/i; s> print = "<a href=\"$author/$filename\">$filename</a>"; s> } s> I need something pretty much the same in php...I just don't know why it s> isn't working quite the same...... s> thanks for your time in advance., s> nixter s> ----------------------------------------------------------- s> Nick.Stankus s> Software Engineer s> Logicon/Sterling Federal s> 402-232-7870 s> ----------------------------------------------------------- s> "There are two things that are infinite; Human stupidity and the s> universe. And I'm not sure about the universe." - Albert Einstein _______________________________________ Massuelles Jean-Baptiste(Juan@acomme.fr) Société A Comme... Tel : 03 80 700 702

« previous php.general (#37850) next »