PHP exec()清除输出

时间:2015-03-24 07:13:22

标签: php arrays output exec

我有一个PHP文件(file.php),代码如下:

<?php
exec("program.exe command",$output);
print_r($output);
?>

在浏览器中打开file.php时,会打印以下输出:

"Array ( [0] => my_output ) "

我只想打印“my_output”。不是“Array ([0] =>”部分。怎么做?

1 个答案:

答案 0 :(得分:0)

示例:

// Correct
print $arr['fruit'];  // apple
print $arr['veggie']; // carrot

print $arr['fruit'];  // apple

尝试使用此代码:

<?php
exec("program.exe command",$output);
echo $output[0];
?>

了解有关数组的更多信息:

  

http://php.net/manual/en/book.array.php

     

http://php.net/manual/en/language.types.array.php

相关问题