How to convert byte array to integer in php?

前端 未结 3 1943
难免孤独
难免孤独 2020-12-11 05:10

I have seen a code that converts integer into byte array. Below is the code on How to convert integer to byte array in php 3 (How to conver

3条回答
  •  难免孤独
    2020-12-11 06:17

    Since L is four bytes long, you know the number of elements of the array. Therefore you can simply perform the operation is reverse:

    $ar = [64,226,1,0];
    $i = unpack("L",pack("C*",$ar[3],$ar[2],$ar[1],$ar[0]));
    

提交回复
热议问题