I have an array like this:
stdClass Object
(
[id] => 1
[name] => John
[email] => lcook0@mail.co.uk
[website] => google.com
[phone] => 0-(343)926-3114
[address] => 620 Main Center
[city] => Fukushima-shi
[country] => JP
[zip] =>
[vat] => 123456
[status] => 1
[created] => 2016-03-10 15:56:44
)
but I will not know the keys and values, since each array will be different. What I need is to insert array into database. Something like:
$keys = '';
$values = '';
foreach ($array as $key => $value) {
$keys .= implode(",", $key);
$values .= implode(",", $value);
}
"INSERT INTO `users` ($keys) VALUES ($values);"
My example does not work, since implode requires an array