Welcome Guest, Not a member yet? Register   Sign In
switch on input->post()
#1

[eluser]Ngulo[/eluser]
hi guys ,i'm getting problems making a simple switch on $this->input->post('asd',TRUE);

i would like to switch in case it is null or is not Null ,any suggestion code?

i really don't know how to make this switch

guessing i would like something like this:

Code:
switch($this->input->post('asd'))
{
case is null:
i do this
break;

case is not null:
i do this other
break;
}

does anyone knows how to build perfectly this switch ?

thanks a lot Wink
#2

[eluser]erik.brannstrom[/eluser]
I don't see why you don't just use a regular if-else statement since you only have two alternatives.

Anyway, the following should work, though you should be aware that switch uses loose comparison (== and not ===), so a value of 0 or FALSE would also be considered to be NULL.

Code:
switch($this->input->post('asd')) {
  case NULL:
    //i do this
    break;
  default:
    //i do this other
}
#3

[eluser]Ngulo[/eluser]
sorry man you are right Wink

the story is that i have more than 2 cases and i was looking to didn't post all my code wich is so longer than the one i posted Wink

thanks for suggestion Wink




Theme © iAndrew 2016 - Forum software by © MyBB