Reputation: 1618
I have a function that reads a config file and then makes variables from the values in the file.
$arr is an array of values read from a text file and then this is turned into variables.
foreach ($arr as $k => $v) {
${$k} = trim($v);
}
This is all done within a function. However I'd like to use the variables created elsewhere in the page. As they are dynamically created I don't know what they will all be called.
Is there any way to do this ?
Thanks
Upvotes: 0
Views: 42
Reputation: 187
EDIT : Push them all in an array in your function and get the array elsewhere.
Upvotes: 0