Skip to content
Advertisement

How to access multiple variables outside foreach loop in php

I am not a php pro and have already explored different online search forums but could not find any suitable answer and that’s why posting my question here.

Function One: Runs a query to database and define variables in foreach loop as follows:

Function two: Now I want to get the values of those variables in another function as follows:

But it does not work. It seems I may need to wrap variables in the foreach loop into an array. I don’t understand how to do that.

Any help here would be highly appreciated.

Thanks in advance.

Bakar

Advertisement

Answer

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement