I'm busy translating a piece of python to PHP. PHP i know, but Python not so much.
Of all the code, I have 5 lines left which I can not translate. Is there someone who is willing to help me with this?
items = []
items.append(s0 >> 0)
items.append(s0 >> 8)
items.append((s0 >> 16) | (s1 << 5))
items.append(s1 >> 3)
newb = b''
for i in items:
tmp = i.to_bytes((i.bit_length() + 7) // 8, byteorder='little')
localnewbyte = bytes([tmp[0]])
newb += localnewbyte
The above part should be something like this, if I'm correct:
$aItems = [];
$aItems[] = ($s0 >> 0);
$aItems[] = ($s0 >> 8);
$aItems[] = (($s0 >> 16) | ($s1 << 5));
$aItems[] = ($s1 >> 3);
for($i = 0; $i < count($aItems); $i++)
{
}
But this is as far as I get, please help. Thanks!
localnewbytewill be a “bytes” object, which is an immutable sequence of integers in the range 0 <= x < 256, so what would this be in PHP an array???