- var_dump: documentation ( source)
- hex2bin: documentation ( source)
- preg_replace: documentation ( source)
- ord: documentation ( source)
<?php
$availablePieces = [];
$bitfield = hex2bin(preg_replace('(\s)', '', 'ffffffff
ffffffff
ffffffff
ffffffff
ffffffff
ffffffff
ffffffff
ffffffff
ffffffff
ffffffff
ffffffff
ffffffff
ffffffff
ffffffff
ffffffff
ffffffff
ffffffff
ffffffff
ffffffff
ffffe0'));
for ($i = 0; $i < strlen($bitfield); $i++) {
$char = ord($bitfield[$i]);
for ($j = 0; $j < 8; $j++) {
$availablePieces[] = ($char & (0b10000000 >> $j)) !== 0;
}
}
var_dump($availablePieces);