louis_coetzee Posted May 28, 2009 Share Posted May 28, 2009 case 128..255: $result = $val2.'['.(Ord($value[$i])).']'; break; Is it possible to do it this way? How am I supposed to do it? Please help. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/159998-switch-problem-please-have-a-look/ Share on other sites More sharing options...
MadTechie Posted May 28, 2009 Share Posted May 28, 2009 Is it possible to do it this way? Does it work ? How am I supposed to do it? What are you trying to do ? Quote Link to comment https://forums.phpfreaks.com/topic/159998-switch-problem-please-have-a-look/#findComment-843971 Share on other sites More sharing options...
redarrow Posted May 28, 2009 Share Posted May 28, 2009 what the hell is that? can you post the full code please? switch name_of_switch($name_of_varable_for_the_switch); name_of_the_condition: $condition_value; //code to do some think if condition match break //ect ect ect Quote Link to comment https://forums.phpfreaks.com/topic/159998-switch-problem-please-have-a-look/#findComment-843972 Share on other sites More sharing options...
trq Posted May 28, 2009 Share Posted May 28, 2009 What way? Your code makes little sense! Are you looking to check your value is within the range of 128 - 255 ? Quote Link to comment https://forums.phpfreaks.com/topic/159998-switch-problem-please-have-a-look/#findComment-843973 Share on other sites More sharing options...
louis_coetzee Posted May 28, 2009 Author Share Posted May 28, 2009 function encrypt($value) { $Result = ''; for ($i = 1; $i <= strlen($value); $i++){ $result = $val2; switch (Ord($value[$i])){ case 0 : $result = $val2.'[NULL]'; break; case 1 : $result = $val2.'[sOH]'; break; case 2 : $result = $val2.'[sTX]'; break; case 3 : $result = $val2.'[ETX]'; break; case 4 : $result = $val2.'[EOT]'; break; case 5 : $result = $val2.'[ENQ]'; break; case 6 : $result = $val2.'[ACK]'; break; case 7 : $result = $val2.'[bEL]'; break; case 8 : $result = $val2.'[bS]'; break; ............... ................ .............. case 122: $result = $val2.'C'; break; case 127: $result = $val2.'[DEL]'; break; case 128..255: $result = $val2.'['.(Ord($value[$i])).']'; break; defualt: $result = $val2.$value[$i]; break; } } } Quote Link to comment https://forums.phpfreaks.com/topic/159998-switch-problem-please-have-a-look/#findComment-843975 Share on other sites More sharing options...
trq Posted May 28, 2009 Share Posted May 28, 2009 What is your question? Quote Link to comment https://forums.phpfreaks.com/topic/159998-switch-problem-please-have-a-look/#findComment-843976 Share on other sites More sharing options...
louis_coetzee Posted May 28, 2009 Author Share Posted May 28, 2009 What way? Your code makes little sense! Are you looking to check your value is within the range of 128 - 255 ? Yep, exactly what I am trying to do. Quote Link to comment https://forums.phpfreaks.com/topic/159998-switch-problem-please-have-a-look/#findComment-843977 Share on other sites More sharing options...
MadTechie Posted May 28, 2009 Share Posted May 28, 2009 Erm.. you could do this <?php switch($X) { case ($X >= 128 && $X <= 255): $result = $val2.'['.(Ord($value[$i])).']'; break; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/159998-switch-problem-please-have-a-look/#findComment-843978 Share on other sites More sharing options...
trq Posted May 28, 2009 Share Posted May 28, 2009 Erm.. you could do this <?php switch($X) { case ($X >= 128 && $X <= 255): $result = $val2.'['.(Ord($value[$i])).']'; break; } ?> No you couldn't. That would need to be.... <?php switch(true) { case ($X >= 128 && $X <= 255): $result = $val2.'['.(Ord($value[$i])).']'; break; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/159998-switch-problem-please-have-a-look/#findComment-843983 Share on other sites More sharing options...
MadTechie Posted May 28, 2009 Share Posted May 28, 2009 No you couldn't. That would need to be.... <?php switch(true) You could as if $X is over 0 then its also true but thats a valid point as if you had a case of 0 mine wouldn't work Quote Link to comment https://forums.phpfreaks.com/topic/159998-switch-problem-please-have-a-look/#findComment-843990 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.