Suppose i have script that calls up a configuration for name of months.
Which one i'll use depends on what script is calling the configuration file.
So, assume that i have these in my configuration file:
Would it be more efficient if i change the above to:
In my configuration file, there are more than 4 arrays defined, but i'll probably use only about 2-3 of them for a script that i'm executing.
So, my question is:
Will it be more efficient/effective/etc to just define all the arrays regardless of whether i'll use them, or is it better to have a bunch of if() statements that will create the arrays only as necessary?
Thanks.
Which one i'll use depends on what script is calling the configuration file.
So, assume that i have these in my configuration file:
$regMonth = array ("Jan", "Feb", "Mar", "Dec");
$crazyMonth = array ("ABC", "DEF", "GHI", "JLK");
$numericMonth = array ("01", "02", "03", "12");
$otherMonth = array ("j4n", "f3b", "m4r", "d3c");
Would it be more efficient if i change the above to:
if ($arg1 == "regular") {
$regMonth = array ("Jan", "Feb", "Mar", "Dec");
}
if ($arg2 == "crazy") {
$crazyMonth = array ("ABC", "DEF", "GHI", "JLK");
}
if ($arg3 == "numeric") {
$numericMonth = array ("01", "02", "03", "12");
}
if ($arg4 == "other") {
$otherMonth = array ("j4n", "f3b", "m4r", "d3c");
}
In my configuration file, there are more than 4 arrays defined, but i'll probably use only about 2-3 of them for a script that i'm executing.
So, my question is:
Will it be more efficient/effective/etc to just define all the arrays regardless of whether i'll use them, or is it better to have a bunch of if() statements that will create the arrays only as necessary?
Thanks.