I want to take an array, loop it with a foreach loop, and have each array value be sent through a class to get data from a database. This is the code I am currently using:
foreach ($unique_category as $key => $value)
{
$category = $value;
$value = new database;
$value->SetMysqli($mysqli);
$value->SetCategory($category);
$value->query_category();
${"$value_category"} = $value->multi_dim_array();
print_r(${"$value_category"});
echo "<br /><br />";
}
print_r($unique_category[0]."_category");
I want the variable $unique_category[0]."_category"
to be ${"$value_category"}
.
Currently, the ${"$value_category"}
in the foreach loop prints out the correct value/array, while $unique_category[0]."_category"
just prints person_category (person being the first value in that array).
How would I go about making $unique_category[0]."_category"
print the same thing as ${"$value_category"}
?
Thank you
EDIT:
The foreach loop is making a multidimensional array that looks something like this Array ( [0] => Array ( [0] => Home [1] => 9.8 ) [1] => Array ( [0] => Penny [1] => 8.2 ))
I want to be able to print out this array outside the foreach loop, with each md array having its own variable name so I can print them out wherever and whenever I want.