Home > php > PHP: get rank value and convert in level - function()

PHP: get rank value and convert in level - function()

January 12Hits:0
Advertisement

I got a function that must to convert a rank value (i.e. 35 exp) and convert into the related level (i.e. Level 2)

function level($rank) {         if ( $rank  = 0    && $rank >= 5    )   { $level = 1; }     elseif ( $rank <= 6    && $rank >= 20   )   { $level = 2; }     elseif ( $rank <= 21   && $rank >= 50   )   { $level = 3; }     elseif ( $rank <= 51   && $rank >= 100  )   { $level = 4; }     elseif ( $rank <= 101  && $rank >= 500  )   { $level = 5; }     elseif ( $rank <= 501  && $rank >= 1000 )   { $level = 6; }     elseif ( $rank <= 1001 && $rank >= 2500 )   { $level = 7; }     elseif ( $rank <= 2501 && $rank >= 5000 )   { $level = 8; }      return $level; } 

But this don't work, i got undefined value for $level.

Where is the error? Thanks to all who can help

Answers

=is for assignation

== is for compareason

function level($rank) {
        if ( $rank  == 0    && $rank >= 5    )   { $level = 1; }
    elseif ( $rank <= 6    && $rank >= 20   )   { $level = 2; }
    elseif ( $rank <= 21   && $rank >= 50   )   { $level = 3; }
    elseif ( $rank <= 51   && $rank >= 100  )   { $level = 4; }
    elseif ( $rank <= 101  && $rank >= 500  )   { $level = 5; }
    elseif ( $rank <= 501  && $rank >= 1000 )   { $level = 6; }
    elseif ( $rank <= 1001 && $rank >= 2500 )   { $level = 7; }
    elseif ( $rank <= 2501 && $rank >= 5000 )   { $level = 8; }

    return $level;
}

Tags:php, math, operators

Related Articles

  • PHP: get rank value and convert in level - function()January 12

    I got a function that must to convert a rank value (i.e. 35 exp) and convert into the related level (i.e. Level 2) function level($rank) { if ( $rank = 0 && $rank >= 5 ) { $level = 1; } elseif ( $rank <= 6 && $rank >= 20 ) { $leve

  • How to convert this recursive function to a iterative one? (var_dump in javascript)January 19

    I'm new here and I'm trying to convert a recursive function to iterative. I have been reading about the subject for some days and I have found some good sites that gave me ideas to try. But I couldn't find a working solution so far. This is the code

  • Is there some file browser that uses low level functions to browse hard disk?February 16

    I have Windows 7, NTFS hard disk. I have detected rootkit files but can't delete them through Windows explorer, obviously because they are not visible. Is there some other file browser that is using low level function calls, lower that win api, so th

  • @staticmethod vs module-level functionOctober 25

    This is not about @staticmethod and @classmethod! I know how staticmethod works. What I want to know is the proper use cases for @staticmethod vs. a module-level function. I've googled this question, and it seems there's some general agreement that m

  • convert deprecated opengl function to modern opengl (3.3) May 27

    i need help to convert the render function of IQM model (void renderiqm()) to modern OpenGL (without the deprecated functions like enableClientState(), etc). The code of renderiqm() function is here: https://github.com/lsalzman/iqm/blob/master/demo/g

  • UML class diagram symbol for a top-level functionNovember 2

    In UML class diagram notation, how do I denote a top-level function that doesn't have any encapsulating class or other structure? e.g. I have a function used for retrieving data from a URL. Since it is a function (in the math sense) of only its param

  • The time complexity for converting any boolean function to DNF(disjunctive normal form)?January 20

    What is the time complexity for converting any boolean function to DNF? Is there a efficient way converting any boolean function to DNF in polynomial time?

  • get date of 3rd friday in the month with SQL without using level functionJanuary 22

    get date of 3rd Friday in the month with SQL (without using level function), also Business days in a month & 3rd Friday for all months, thank you --------------Solutions------------- Here's something that will get you the 3rd Friday in the month for

  • Is there a way to reference the Java class for a Kotlin top-level function?January 22

    I want to load a resource in a top level function using Class.getResourceAsStream(). Is there any way to get a reference to the class that the top level function will be compiled into so that I can write, for example val myThing = readFromStream(MYCL

  • Circuit to Convert Line Level to Mic Level

    Circuit to Convert Line Level to Mic LevelApril 9

    How would I design a circuit that converts a line level signal to be able to be fed into a microphone input? The input impedance of the microphone jack is 2 kohms. --------------Solutions------------- I would use a simple resistor divider: This atten

  • How to convert DTED Level 1 into SRTM DTEDMarch 11

    We have a GIS tool that handles only SRTM DTED level 1 terrain files. SRTM level 1 terrain files are limited to 60 deg lat. So I need to fill up the gap from 60 lat up to 90 deg lat. I have DTED level 1 data covering the area 60 deg lat and upwards t

  • Convert TTL levels to RS232 of FTDI USB - Serial

    Convert TTL levels to RS232 of FTDI USB - SerialJanuary 7

    Have this small interface FTDI FT232RL to connect a Serial device to the computer via USB. It has been working well for most of my Serial applications, except today when I tried to use it for a Roboteq controller. While all settings are correct, char

  • R ggmap countour plot: Convert ..level.. to events per squared area of distanceJanuary 22

    Using the example in ggmap: Spatial Visualization with ggplot2, by David Kahle and Hadley Wickham of a filled contour plot of violent crimes (Figure 9 in the linked article), I would like to know if instead of ..level.., how I could instead show aver

  • Converting the level.dat file from Minecraft to a map

    Converting the level.dat file from Minecraft to a mapFebruary 13

    Minecraft backups are saved to a local folder on your computer. C:\Users\USERNAME\AppData\Roaming.minecraft\saves How can such a file be utilized from FME? Turning it into a map will require a rule set where one decides if the map/visualization shoul

  • Converting any PHP function toString() like in JSJune 14

    In JavaScript, any function is basically an object on which you can call (function(){}).toString() to get it's underlying code as a string. I'm working on a function aimed to do the job in PHP. The intended goal is to convert code from PHP into other

  • how to convert this php function to jquery function. It returns every possible combination of the values from an array.February 9

    I found this PHP code from here: function everyCombination($array) { $arrayCount = count($array); $maxCombinations = pow($arrayCount, $arrayCount); $returnArray = array(); $conversionArray = array(); foreach ($array as $key => $value) { $conversionAr

  • how to advance into higher level functional programming August 20

    first my apologies if this isn't the right place for this question but I think that th.CS is not the right place for sure neither is StackOverflow. I really like functional programming and I think I'm a medium level guy in F# and understand the basic

  • What score/level function is often used?October 22

    In many games you raise a level when you reach a certain score, and later levels are harder to reach than in the beginning. I am suspecting that it is some sort of exponential function that is used in e.g. WoW. Does anyone know of a good exponential

  • Using both Ctrl+Alt to replace AltGr 3rd level function on xorgJanuary 31

    On Windows, Ctrl-Alt is mapped to Alt Gr, but not so on Linux. Using Alt Gr for 3rd level keys is wrist-killer! I'm unable to find a workaround that doesn't remove other functionality I use (the few mapping options in keyboard settings). I found refe

  • How to format an Intel 320 SSD to take advantages from their wear leveling function?March 11

    Since that i can't use TRIM, i wanted to setup in my SSD disks a free space (10%) so that the SSD's controller uses that to do the wear leveling. How can i do that? With fdisk? Also, i read this online: what's the changed situation with partitions on

Copyright (C) 2018 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 0.671 s.