- var_dump: documentation ( source)
- decbin: documentation ( source)
- strrev: documentation ( source)
- pow: documentation ( source)
- str_split: documentation ( source)
<?php
$value = 1023;
$value = decbin($value);
$value = str_split(strrev($value));
$bitValues = array();
foreach($value as $pos => $bit) {
if (0 != $bit) {
$bitValues[] = pow(2, $pos);
}
}
var_dump($bitValues);