You can do this:
function exponentArr($num){
$arr = array();
for($i=0;$i <= $num;$i++){
$arr[$i] = pow(2, $i);
}
return $arr;
}
This will give you an array $arr
with the required output.
2
solved How to print power series in php