// Создаю массив $aYearColor = array_fill(0,366,'#FFFFFF'); // Запаковываю его $aYearColorBlob = pack('a*', ...$aYearColor); // Распаковываю unpack('a*', $aYearColorBlob); 

But this method will not work. The output will be array (1 => #FFFFFF);

And the Error Warning: pack (): 365 arguments unused in ...

If the array is numeric, then there is no problem, everything will work:

 $aYearOrder = array_fill(0,366,0); $aYearOrderBlob = pack('i*', ...$aYearOrder); unpack('i*', $aYearOrderBlob); 

Read that:

For a, A, h, H, the number of repetitions determines how many characters are taken from one data argument.

But I don’t understand how to add such an array with string values ​​and then unpack it back. thank

    1 answer 1

    Since in my case I need to store the color in an array, I transferred the system from 16 to 10 and packed the numeric array.