<?PHP echo pow(2,4); //16 echo pow(-2,3); //-8 echo pow(8,-3); //0.001953125, =1/pow(8,3) ?>
Example of float parameters.
<?PHP echo pow(3.4,2.1); //13.064889045095 ?>
For nth root of number x (n√x):
<?PHP echo pow(3.4,1/5); //5th root of 3.4, =1.277308 echo pow(8,1/3); //cube root of 8, =2 ?>
<?PHP echo 2**3; //8 ?>
The following customized function
<?PHP function powx(&$arr, $x) { for ($ii=0;$ii<count($arr);$ii++) $arr[$ii] = pow($x,$arr[$ii]); } $arr2 = array("2","3.4","5.342","0","3","-5","6.3"); powx($arr2,2); print_r($arr2); //the result is: Array ( [0] => 4 [1] => 10.556063286183 [2] => 40.560400705102 [3] => 1 [4] => 8 [5] => 0.03125 [6] => 78.793242454075 ) ?>