snmpwalk在PHP表中返回字符串。如何分开?

snmpwalk在PHP表中返回字符串。如何分开?,php,Php,抱歉,我们已经处理了数小时的数据,我们可以想出一种方法来实现这一点 我正在执行一个php shell_exec snmpbulkwalk 例如: $counts = shell_exec("/bin/snmpbulkwalk -v 2c $hostname ..... | awk '{print \$4}' "); print "<table border=1 bgcolor=#ffffff>"; print "<tr> <td>Coun

抱歉,我们已经处理了数小时的数据,我们可以想出一种方法来实现这一点

我正在执行一个php shell_exec snmpbulkwalk

例如:

 $counts = shell_exec("/bin/snmpbulkwalk -v 2c $hostname ..... | awk  '{print \$4}' ");
print "<table border=1 bgcolor=#ffffff>"; 
print "<tr>
       <td>Counts</td>
       </tr>"; 

for ($i=0; $i<count($counts); $i++) {
         print "<tr>";
         print "<td>$counts[$i]</td>";
print "</tr>"; } 
print "</table>";
Counts
890 718 600 577 602 309 924 685 651 204 485 709 341 369 3 39 728 638 556 3 1013 639 476 591 672 774 307 736 586 507 539 467 684 609 760 839 721 735 431 795 868 491 587 581 575 414 299 234
Counts
890 
718 
600 
577 
...
echo "<pre>".$counts."</pre>"
我想把它印在一张表格里

例如:

 $counts = shell_exec("/bin/snmpbulkwalk -v 2c $hostname ..... | awk  '{print \$4}' ");
print "<table border=1 bgcolor=#ffffff>"; 
print "<tr>
       <td>Counts</td>
       </tr>"; 

for ($i=0; $i<count($counts); $i++) {
         print "<tr>";
         print "<td>$counts[$i]</td>";
print "</tr>"; } 
print "</table>";
Counts
890 718 600 577 602 309 924 685 651 204 485 709 341 369 3 39 728 638 556 3 1013 639 476 591 672 774 307 736 586 507 539 467 684 609 760 839 721 735 431 795 868 491 587 581 575 414 299 234
Counts
890 
718 
600 
577 
...
echo "<pre>".$counts."</pre>"
我希望每个值都在自己的行中

例如:

 $counts = shell_exec("/bin/snmpbulkwalk -v 2c $hostname ..... | awk  '{print \$4}' ");
print "<table border=1 bgcolor=#ffffff>"; 
print "<tr>
       <td>Counts</td>
       </tr>"; 

for ($i=0; $i<count($counts); $i++) {
         print "<tr>";
         print "<td>$counts[$i]</td>";
print "</tr>"; } 
print "</table>";
Counts
890 718 600 577 602 309 924 685 651 204 485 709 341 369 3 39 728 638 556 3 1013 639 476 591 672 774 307 736 586 507 539 467 684 609 760 839 721 735 431 795 868 491 587 581 575 414 299 234
Counts
890 
718 
600 
577 
...
echo "<pre>".$counts."</pre>"
这似乎很基本,但我不确定我是否了解如何修复

我知道在过去,如果用下面的php回声显示。但是我需要把这些数据放到一个表中

例如:

 $counts = shell_exec("/bin/snmpbulkwalk -v 2c $hostname ..... | awk  '{print \$4}' ");
print "<table border=1 bgcolor=#ffffff>"; 
print "<tr>
       <td>Counts</td>
       </tr>"; 

for ($i=0; $i<count($counts); $i++) {
         print "<tr>";
         print "<td>$counts[$i]</td>";
print "</tr>"; } 
print "</table>";
Counts
890 718 600 577 602 309 924 685 651 204 485 709 341 369 3 39 728 638 556 3 1013 639 476 591 672 774 307 736 586 507 539 467 684 609 760 839 721 735 431 795 868 491 587 581 575 414 299 234
Counts
890 
718 
600 
577 
...
echo "<pre>".$counts."</pre>"
echo“$counts”

谢谢您的帮助。

shell\u exec
之后使用
$counts=explode(“,$counts”)
它获取表的数组。在
shell_exec
之后使用
$counts=explode(“,$counts”)它获取表的数组。