I'm trying to write an algorithm to find the GCD ( Greatest common divisor ) but the result of my function is `Array` what I'm doing wrong !! please I don't want another aproche or a ready algorithme copie past I wanna know what i'm doing wrong

```
<?php 

function pgcd($val1, $val2){

    if (!is_numeric($val1) || !is_numeric($val2)){

        return null;
    }

    $i = 1;
    $final = array();

    while($i <= min($val1, $val2)){

        if ($i % $val1 === 0 && $i % $val2 === 0){
            $final[] = $i;

        }

        $i++;
    }

    return $final;
}

echo pgcd(120,420);

 ?>

```