PHP doesn't actually have variable declaration. That means in some cases you can reference variables without actually having them declared beforehand. I say some cases because:
foreach($undefinedArray as $key=>$value){
// will give a notice and a warning
// notice: undefined variable
// warning: invalid argument to foreach
}
But this doesn't mean you can't do something like so:
for($i=0;$i<5;$i++){
$undefinedArray[]=$i;
}
// will create an array with 5 indexes, each holding the numbers 0 through 4
This works because $undefinedArray is not found and created on the fly.
Now, regarding your own case. I'm gonna assume you mean this post. And I have to admit, that's a very interesting solution, I'm gonna try to restrain myself from commenting on any kind of bad practice there, but let's get on to explaining it!
$params[] = &$row[$field->name];
This is where the magic happens and it's actually due to the &. Because &$row['unknown_index'], actually creates the index!
This means that above statement does 2 things. First it creates an array with each column name saved as an index in $row ($row[$field->name]). Then it saves a pointer to each of the elements from $row in $params.
call_user_func_array(array($stmt, 'bind_result'), $params);
This does $stmt->bind_result(). But passes each of the elements in $params as parameters to bind_result. And since they're passed by reference, each index of $row will hold each of the selected fields.
The rest should be easy to figure out now.
If you got any questions. Feel free to ask!