How to call another function inside query result while loop and get results

When you say “there is a problem with my code”, it would be easier to spot if you could tell us how it doesn’t work the way you expect it to.

This bit doesn’t look right, at the end of the getForumSection() function definition:

            return $sections;
            return $groups;

From the documentation: “If called from within a function, the return statement immediately ends execution of the current function, and returns its argument as the value of the function call.” - so it will never hit the second return because the first has exited the function, and so your calling code won’t have access to $groups[]. You could return the two arrays as members of another array, or create an object to contain them, or no doubt several other ways.

Is that what the problem was?

1 Like