Hello,
I am creating a series of arrays from template tags in a content management system, and outputting the titles of these arrays as arrays labeled with variables:
<Loop>
$<GeneratedArrayName1> = array( "foo" => "bar" );
$<GeneratedArrayName2> = array( "foo" => "bar" );
</Loop>
I'm also generating another array of possible GeneratedArrayNames and sorting it by count. I'm looping through this array to get the GeneratedArrayNames so I can selectively show them. After I sort, I want to pull and display only a few of the many arrays I have with GeneratedArrayNames. I'm doing this by positioning the pointer at the top of the master array and getting the name:
reset($ArrayNames);
$firstArray = current($ArrayNames); //outputs GeneratedArrayName1
Then I went to pull the GeneratedArrayName by getting the Variable variable, which gives me an error:
print_r(${$firstArray}); // outputs Undefined variable: GeneratedArrayName1
But when I hardcode, I get the correct data:
print_r($GeneratedArrayName1); // outputs the array
Where am I going wrong?
EDIT
I am getting $firstArray
by this loop:
$count = 0;
foreach($ArrayNames as $ArrayCount => $ArrayName) {
$count++;
echo "$ArrayName" . ' - ' . "$ArrayCount" . '<br>';
if ($count >= 3) {
break;
}
} //from here I proceed to reset($ArrayNames)