1) { $dhcpdata['DNS1'] = $arrDns[1]; } if (count($arrDns) > 2) { $dhcpdata['DNS2'] = $arrDns[2]; } } } // fetch dhcpcd.conf settings for interface $conf = file_get_contents(RASPI_DHCPCD_CONFIG); preg_match('/^#\sRaspAP\s'.$interface.'.*?(?=\s*^\s*$)/ms', $conf, $matched); preg_match('/metric\s(\d*)/', $matched[0], $metric); preg_match('/static\sip_address=(.*)/', $matched[0], $static_ip); preg_match('/static\srouters=(.*)/', $matched[0], $static_routers); preg_match('/static\sdomain_name_servers=(.*)/', $matched[0], $static_dns); preg_match('/fallback\sstatic_'.$interface.'/', $matched[0], $fallback); $dhcpdata['Metric'] = $metric[1]; $dhcpdata['StaticIP'] = $static_ip[1]; $dhcpdata['StaticRouters'] = $static_routers[1]; $dhcpdata['StaticDNS'] = $static_dns[1]; $dhcpdata['FallbackEnabled'] = empty($fallback) ? false: true; echo json_encode($dhcpdata); }