• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 311
  • Last Modified:

Function to calculate value

Hi all, I need to create a function that will do the following:
receive a value of a variable, and depending on the value of this variable assign to another variable another value. The range is up to 105 from 1, so to create a switch would be kind of long, if someone have another way to do this would be appreciated.
Thanks in advance.
switch ($variableReceived) 
    case 105:
        $var1 = 105;
		$varNormal = 35;
    case 104:
        $var1 = 104;
		$varNormal = 30;

Open in new window

  • 2
1 Solution
Guy Hengel [angelIII / a3]Billing EngineerCommented:
what is the logic from the values function?
doRodrigoAuthor Commented:
Well the value function should receive a value, like:


And receiving this $variable should be used to know what is the correspondent value, something like:

switch ($stat) //where stat would be 100
    case 100:
        $var1 = 100;
            $varNormal = 35;

So the $var1 would have the same value as the one passed, the $varNormal would now receive the corresponding value to the value 100.

Did you understand it angelIII?
switch looks good unless there is a mathematical correlation or unless you want to to change the values. if the valus are going to change it would be better to use a database to get the info so you don't have to change the program.
Guy Hengel [angelIII / a3]Billing EngineerCommented:
sorry, but I still don't understand the "problem" :(
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now