[Solved] How do I return an integer array the sum of which equals to a given number in php? [closed]


mkasberg provided the solution:

   $in = 72;
   $out = array();
   $a = array_reverse(str_split((string)decbin($in)));
    foreach($a as $k => $v){
       if ($v != "0") array_push($out, pow(2,$k));
    }

0

solved How do I return an integer array the sum of which equals to a given number in php? [closed]