I have tried the below solution but i dont see why i dont the get the results right , any help is appreciated. Thanks a lot.
function binaryArrayToNumber($arr) {
$sumarr = [];
for($i=count($arr);$i>0 ;$i--){
$power= pow(2,($i-1));
$sumarr[]=$power*$arr[$i-1];
}
return array_sum($sumarr);
}
Example answer would be Testing: [1, 1, 1, 1] ==> 15 Testing: [1, 0, 1, 1] ==> 11