I'm starting to do web development. My requirement here is a bit unique. I have a set of points, score_1 - score_n. Each point is associated with a factor with which it affects a grand score. Now I want to write the configuration.php file as:
<?php define("NUMBER_SCORES",4,true); define("FACT_SCORE[1]",0.2,TRUE); define("FACT_SCORE[2]",0.6,TRUE); define("FACT_SCORE[3]",0.8,TRUE); define("FACT_SCORE[4]",0.6,TRUE); define("FACT_SCORE[5]",0.7,TRUE); ?>
and then I want to iterate over these values as follows:
<?php function grand_total() { $agg_score=0; for($i=1;$i<=number_scores+1;$i++) $agg_score=$agg_score+ (FACT_SCORE[$i])*$scores[$i]; return $agg_score; } ?>
Well, I know that this is the wrong way to do this, but I can’t understand how I achieved this functionality? The configuration.php file is often modified to meet the desired requirements, while many other pages use the data in it. Is there any other way to achieve this?
source share