Jump to content

switch problem - Please have a look


louis_coetzee

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.