Hello all,
Say you have this defined in your html form:
<input name="someform[somefield]" value="someval">
How come in PHP this does not work:
$field_name = "someform[somefield]";
print ${$field_name};
// outputs blank
But on the other hand this works:
$form_name = "someform";
print ${$form_name}[somefield];
// outputs "someval
What the 😕 ???
In short, as soon as a variable name is referencing an array, the corresponding string cannot be used to reference another variable.
// won't work
$var_name = "array_name[field_name]";
print ${$var_name};
I am trying to understand for what fundamental reason it can't work and what are good workarounds for this?
Thanks for any info!