Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5980619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:49:37+00:00 2026-05-22T21:49:37+00:00

I am a starter in web development. My requirement in a bit unique here.

  • 0

I am a starter in web development. My requirement in a bit unique here. I have a set of scores, score_1 to score_n. Each score is associated with a factor with which it affects the grand score. Now I wish to write a 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 wish to iterate over these values like this:

<?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 not the right way to do it, but I can’t figure out how I attain this functionality? The configuration.php file is often changed to meet the desired requirements while many other pages use the data in it. Is there any other way of achieving this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:49:38+00:00Added an answer on May 22, 2026 at 9:49 pm

    If you have constants with fancy names, you need to use constant() to call them:

    constant('FACT_SCORE[' . $i . ']')
    

    Of course, given that it isn’t an array, it may be less confusing to get rid of square brackets:

    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);
    

    Or simply use an array 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just started web development after a few years. Mostly in the past
I've been away from web design/development for a long, long now and have recently
I am just getting started on web app development. I have an index.jsp that
I'm new to web development and have started using JSONP and Google's Feed API
I have been searching for the perfect web development IDE for some time now.
I have started design of a ColdFusion application that is entirely web based. Not
I've been a web developer for some time now, and have recently started learning
Using JDeveloper , I started developing a set of web pages for a project
Hi I am new to Struts 2 and all the java web development, I
I'v just started learning different languages in web development and I believe the best

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.