Search code examples
phpsnmp

PHP snmp return result


I use this function for get result by snmp
snmp2_walk("localhost", "private", "OID");

All work fine, but result returns in this form:
STRING: "..."
STRING: "second"

Is there a function to convert this result into a normal string?
From STRING: "second" to second


Solution

  • I believe this is what you're looking for:

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

    https://www.php.net/manual/en/ref.snmp.php