$num = 10;
for($i = 0; $i < 8; $i++) {
$bit = ($num >> $i) & 1;
// 进行操作
}
$num = 10;
$i = 0;
while($num > 0) {
$bit = $num & 1;
// 进行操作
$num >>= 1;
$i++;
}
$num = 10;
$binary = decbin($num);
$binaryArray = str_split($binary);
foreach($binaryArray as $bit) {
// 进行操作
}