null, 'mask' => null, ]; } // 匹配 IPv4 地址 if ($interface && preg_match('/inet ([\d\.]+)/', $line, $matches)) { $interfaces[$interface]['ip'] = $matches[1]; } // 匹配子网掩码 if ($interface && preg_match('/netmask ([\d\.]+)/', $line, $matches)) { $interfaces[$interface]['mask'] = $matches[1]; } } // 输出调试信息,检查解析到的接口 error_log(print_r($interfaces, true)); return $interfaces; } }