PHP SNMP snmpwalk Hex-STRING和STRING混合解析方法

                        $split = explode(':', $soft[1][$i], 2);
                        if ( strcmp($split[0], 'Hex-STRING') == 0 ) {
                        //        if ($hex) {
                            $hex = str_replace(' ', '', $split[1]);
                            $hex = preg_replace('/[^a-zA-Z0-9]+/', '', $hex);
                            $hex = hex2bin($hex);
                            $installed_name[$i] = $hex;
                        } else{
                            $data = str_replace('STRING: ', '', $soft[1][$i]);
                            $data = str_replace('"', '', $data);
                            $installed_name[$i] = $data;
                        }

猜你喜欢

转载自blog.csdn.net/allway2/article/details/92187629