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;
}
```