0
votes

I am trying to get multiple snmp polls to show up in a table and i cant figure it out. here is a sample:

        function fec31($ip){
        echo '<FORM method="post" name="FormFec31" action="./fec31.php">
                Ip: <INPUT type="text" size="20" name="ip" value="'.$_POST['ip'].'"><BR>

                <INPUT type="submit" name="btnsubmit" value="Submit"><BR><BR>
                </FORM>
        ';
                echo "3.1 fec<br><table>";
                $a = array(
                 "1" => snmp2_walk($ip, "public", ".1.3.6.1.4.1.4491.2.1.28.1.10.1.3"),
                 "2" => snmp2_walk($ip, "public", ".1.3.6.1.4.1.4491.2.1.28.1.10.1.4"),
                 "3" => snmp2_walk($ip, "public", ".1.3.6.1.4.1.4491.2.1.28.1.10.1.5"),
                );
                echo"<tr><td>Channel</td><td>Total</td><td>Corrected</td><td>Errored</td></tr>";
                $chan = 1;
                while ($chan <= 4) {


                    print "<tr><td>$chan</td><td>{$a['1']}</td><td>{$a['2']}</td><td>{$a['3']}</td></tr>";
                    $chan ++;
                }
                    echo "</table>";

    }

this outputs:

3.1 fec

Notice: Array to string conversion in /var/www/fec31.php on line 52

Notice: Array to string conversion in /var/www/fec31.php on line 52

Notice: Array to string conversion in /var/www/fec31.php on line 52

Notice: Array to string conversion in /var/www/fec31.php on line 52

Notice: Array to string conversion in /var/www/fec31.php on line 52

Notice: Array to string conversion in /var/www/fec31.php on line 52

Notice: Array to string conversion in /var/www/fec31.php on line 52

Notice: Array to string conversion in /var/www/fec31.php on line 52

Notice: Array to string conversion in /var/www/fec31.php on line 52

Notice: Array to string conversion in /var/www/fec31.php on line 52

Notice: Array to string conversion in /var/www/fec31.php on line 52

Notice: Array to string conversion in /var/www/fec31.php on line 52

Channel Total Corrected Errored

1 Array Array Array

2 Array Array Array

3 Array Array Array

4 Array Array Array

1

1 Answers

0
votes

Your issue is that $a['1'] is an array, so $a is an array of arrays. If you do a print_r($a) or even print_r($a['1']), you will see the structure of your data and how to pull it out.

Or, you can set the way the data is returned from the snmpwalk function:

snmp_set_quick_print(1); // print just the value, no types
snmp_set_valueretrieval(SNMP_VALUE_PLAIN); // no quotes for strings