I have a foreach() method where a message for an email is concocted:
foreach($this->fields as $key => $field)
$msg .= "$key : $field \n";
My problem is that I need to create a mysql_query() to insert the field values into my database and I don’t know how I can retrieve that data to actually insert into the database.
How can I get it?
Let me know what other code I need to provide if you need any more.
You can’t create a dynamically named variable inside a foreach loop. What you can do, though, is create an array of keys with $field as the value:
However, this is kind of roundabout, because you can just get the same behavior by getting it like this:
I hope I understood your question correctly through your comments.