在PHP中创建字节数组

I have to convert an existing Java code for encryption to PHP. I am stuck in the below Java code where the key is converted to a byte array using Java's BigInteger class

private static byte[] stringToBytes(String str){ 

    byte[] bytes=new BigInteger(str, Character.MAX_RADIX).toByteArray();
    return Arrays.copyOfRange(bytes, 1, bytes.length); 
} 

I am able to convert the input string to big int using

base_convert($key,36,10);

But cannot convert to byte array. Any inputs please

A sample output for Java code is shown below

stringToBytes("TestString")

gives

[10, -100, -89, -107, 122, -108, 44]