'Missing required parameter: domain']); return; } exec("sudo certbot certificates --cert-name $domain | grep 'Expiry' | grep 'Expiry'", $phpOutput, $phpReturnCode); if(empty($phpOutput)){ echo json_encode([ 'ssl_expiry' => "-", 'ssl_remaining' => "-" ]); } else { $sslData = explode(" ",$phpOutput[0]); echo json_encode([ 'ssl_expiry' => $sslData[6], 'ssl_remaining' => $sslData[9] ]); } } }