I have some code that saves xml content to variables. One of those variables can be a number that ranges from 1-240. Based on a range (like 1-30, 30-60, 60-90, etc), I want to save some text to a new variable.
My current code is having issues (I'm fairly new to php, but catch on quick). For instance, my saved variable from the xml document ($storm_wind
) was 100
, which according to my code, should have saved $category
variable as 2
. However, it saves the variable as 5
(which I'm assuming is because my last line in the code is $category = '5';
. What is the proper way to execute this code? Should I be using elseif
statements instead?
Below is a snippet of the code that is currently not working:
$wind_value = $xml->channel->item[0]->nhcCyclone->nhcwind;
$storm_wind = substr($wind_value, 0, -4);
if(($storm_wind >=1) && ($storm_wind <=38); {
$category = 'TD'; }
if($storm_wind >=39 && $storm_wind <=73); {
$category = 'TS'; }
if($storm_wind >=74 && $storm_wind <=95); {
$category = 1; }
if($storm_wind >=96 && $storm_wind <=110 ); {
$category = 2; }
if($storm_wind >=111 && $storm_wind <=129 ); {
$category = 3; }
if($storm_wind >=130 && $storm_wind <=156 ); {
$category = 4; }
if($storm_wind >=157 && $storm_wind <=240 ); {
$category = 5; }