Hi,
In PHP, say that you have some code like this:
$infrastructure = mt_rand(0,100);
if ($infrastructure < $min_infrastructure) $infrastructure = $min_infrastructure;
//do some other stuff with $infrastructure
$country->set_infrastructure($infrastructure);
$education = mt_rand(0,100);
if ($education < $min_education) $education = $min_education;
//do some other stuff with $education
$country->set_education($education);
$healthcare = mt_rand(0,100);
if ($healthcare < $min_healthcare) $healthcare = $min_healthcare;
//do some other stuff with $healthcare
$country->set_healthcare($healthcare);
Is there some way of combining these similar sets of instructions into a function that could be called like:
change_stats("infrastructure");
change_stats("education");
change_stats("healthcare");
Basically, can you use variables in PHP in other variable names and function names?
Thanks in advance.