i want to shift a 16-bit variable in Php. but my code is not working. its just shifts the Lowest nibbles of each Byte. and leave The High nibble unchanged. first and third nibble shifts fine. but second and fourth is not.
public static function leftShift2Byte($in){
$strarr = str_split($in);
if($strarr[1]>chr(127)){
$strarr[1] = $strarr[1]<<1;
$strarr[0] = $strarr[0]<<1;
$strarr[0]++;
}else{
$strarr[1] = $strarr[1]<<1;
$strarr[0] = $strarr[0]<<1;
}
return $strarr[0].$strarr[1];
}