Home>

I want to create a function that cubes the contents of an array when I pass an array of Integer
I also want to create the validation required for the argument in the function
・ Empty check
・ Being an array
・ The contents of the array are numbers

<? php
$nums = array (1,2,3,4,);
$result = exponentiation ($nums);
function exponentiation ($nums) {
    if (empty ($nums)&&is_array ($nums)) {
        echo'error';
    } foreach ($nums as $num) {
        if (is_numeric ($nums)) {
            echo'Error';
        } else {
            echo pow ($num, 3). "\ n";
        }
    }
}

Validation check
・ Empty check
・ Being an array
Processed well.

But,
The validation check process that the contents of the array are numbers
It doesn't work.

As you pointed out, I changed it from $int,
I would appreciate it if you could point out something wrong.