I have a string like this:
$string = '[miniTrack, boxTrack]'
I want to turn it into an array of variables like this:
$array = [$miniTrack, $boxTrack];
So that I can perform loops and iterations through the variable. And access the variables they are referencing.
I tried eval but I can't figure out how to convert it to a PHP Variable.
I KNOW THAT THIS IS NOT IDEAL, THE STRUCTURE OF THE DATABASE THIS IS PULLING FROM CAN'T BE ADJUSTED UNFORTUNATELY
minitrackandboxtrackwill be seen as undefined/unknown constants. YOu'll have to parse the string manually. explode on commas, strip off the[], etc... And frankly, dynamically generating variable names is just a plain bad idea. it's pretty much always a sign of bad design, and will make for insanely ugly code that's nearly impossible to figure out/maintain later on.