Solved

Function to calculate value

Posted on 2009-05-07
4
302 Views
Last Modified: 2013-12-12
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;

        break;

    case 104:

        $var1 = 104;

		$varNormal = 30;

 		break;

...

Open in new window

0
Comment
Question by:doRodrigo
  • 2
4 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24328128
what is the logic from the values function?
0
 

Author Comment

by:doRodrigo
ID: 24328281
Well the value function should receive a value, like:

values($variable);

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

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

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?
0
 
LVL 6

Accepted Solution

by:
mmarth earned 500 total points
ID: 24350966
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.
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24352036
sorry, but I still don't understand the "problem" :(
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now