[PHP-users 1188] Re: プロセスの状況で警告ページに切り替えたい

Shigeki Mimura php-users@php.gr.jp
Tue, 14 Aug 2001 13:19:01 +0900


三村です

kambe> 私が参照したマニュアルは
kambe> http://www.asakawa.ne.jp/doc/php/ja/
kambe> にある2000/02/24版(UNICODE)です。
kambe> 
kambe> これによると、systemでもexecでも、$command_resultには
kambe> 実行した最後の行のみが格納されます。psコマンドの
kambe> 実行結果は複数行にわたることが多いので、これでは
kambe> 少し都合が悪いのです。

execの第2パラメータは最終行だけではありません。
http://www.php.net/manual/en/function.exec.phpを見てみて下さい。
そこにこうあります。

# 適当に改行を入れました。

If the array argument is present, then the specified array
 will be filled with every line of output from the command.
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Note that if the array already contains some elements,
 exec() will append to the end of the array.
 If you do not want the function to append elements,
 call unset() on the array before passing it to exec(). 

下線を入れた部分を見て下さい。
実際に配列に実行結果が入ってきます。
試してみて下さい。