Jump to content

If statements in module config files?


Ragonz

Recommended Posts

So we have a module which accepts custom variables, one of these is an amount of ram.

switch ($params["configoptions"]["Extra Ram"])
{
case "None":  
  $billing_api_values["gamevar_X"] = "1";  
  break;

}

 

Is there a way I can do a statement that says somthing along the lines of if "configoptions"]["Extra Ram" exists, do below, if not exist check for config option B if not exist check config option c if not exist do following

 

Link to comment
Share on other sites

the following IF statement will do what you ask for

if (isset($params["configoptions"]["Option A"]) && !empty($params["configoptions"]["Option A"])){
	// Do Something
}
elseif (isset($params["configoptions"]["Option B"]) && !empty($params["configoptions"]["Option B"])){
	// Do Something
}
elseif (isset($params["configoptions"]["Option C"]) && !empty($params["configoptions"]["Option C"])){
	// Do Something
}
else {
	// No options available do something else
}

 

Link to comment
Share on other sites

so somthing like this

 

if (isset($params["configoptions"]["Extra Ram"]) && !empty($params["configoptions"["Extra Ram"]))
{
case "None":  
  $billing_api_values["gamevar_X"] = "1";  
  break;
case "1GB":
  $billing_api_values["gamevar_X"] = "1024";
  break;  
case "2GB":
  $billing_api_values["gamevar_X"] = "2048";
  break;
}
elseif (isset($params["configoptions"]["Ram"]) && !empty($params["configoptions"["Ram"]))
{
case "512MB":  
  $billing_api_values["gamevar_Xms"] = "512";  
  $billing_api_values["gamevar_Xmx"] = "512";   
  break;
case "1GB":
  $billing_api_values["gamevar_Xms"] = "1024";
  $billing_api_values["gamevar_Xmx"] = "1024";
  break; 
}

else

{

$billing_api_values["gamevar_X"] = "4096";  

}

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated