I ran across this inside a WordPress plugin.
$stuff = $wpdb->get_results(" assume valid database query here ");
foreach ($stuff as $cur)
${$cur->type}[] = $cur->name;
$stuff
will be an object containing more objects of database rows. These database rows will have columns 'id'
, 'type'
, and 'name'
. The 'type'
column will contain one of these three strings: 'file'
, 'url'
, or 'code'
.
It looks like this code snippet will potentially create or add new elements to arrays named $file
, $url
, and/or $code
. However, I'm not familiar with this use of the ${$ } syntax; I've only seen it inside double quoted strings to avoid parsing problems.
Am I correct in my analysis of this code? Where can I learn more about this use of the ${$ } syntax?
There is a question about the ${ } syntax inside a double-quoted string. I understand that use, but I'm specifically asking about a second $ character inside the { } braces.