0

I'm trying to pass an array from one function to the main function (I'm a beginner in PHP). I do this in a way I read on the internet, although I get information about an undefined variable where the function is called in my opinion with the appropriate parameter. What does not play here, I forget something?

function topProducts() {    
    $sql = "MYSQL QUERY";

    $stmt = $connect->prepare($sql);
    $stmt->execute();
    $result = $stmt->fetchAll();

    getCategories($catarray);
    print_r($catarray);    
}

function getCategories($catarray) {    
    $sql = "MYSQL QUERY";

    $stmt = $connect->prepare($sql);
    $stmt->execute();
    $catarray = $stmt->fetchAll();
    return $catarray;    
}
Cerbrus
  • 70,800
  • 18
  • 132
  • 147
sc4rface
  • 29
  • 10

0 Answers0