It’s time to stop searching a just ask. I can’t find an answer online for the life of me. Anyway, I am going through someone else’s code and they have this syntax inside of a loop and I’m not sure exactly what is happening.
foreach($params as $key => $val) {
${$key} = $val
}
It’s the ${$key} that I don’t understand.
It’s assigning all the key-value pairs in an array to actual variables.
${$key}is evaluated twice. It takes the$keyfor that value and evaluates it to a string. So if$keywere the string ‘foo’ then the final operation being done would be$foo = $val.