I have an array that looks like this
Array
(
[0] => Array
(
[post_id] => 5410
[Issue] => 201
[volume] => 2
[pages] => 105-9
[authors] => Onger, M., Jaluth, K.
[publication_date] => 17 January 2016
[journals] => Nature Medicine
[link_to_pubmed] => http://www.ncbi.nlm.nih.gov/pubmed/1
)
[1] => Array
(
[post_id] => 5411
[Issue] => 301
[volume] => 7
[pages] => 32-9
[authors] => Onger, M., Jaluth, K.
[publication_date] => March 30
[journals] => Lancet
[link_to_pubmed] => http://www.ncbi.nlm.nih.gov/pubmed/2
)
)
I have been cracking my head the whole day trying to figure out how i can insert both the key and the value to get something that looks like this
+---------+---------+-------------------+-----------------------+
| meta_id | post_id | meta_key | meta_value |
+---------+---------+-------------------+-----------------------+
| 190143 | 5410 |Issue | 201 |
| 190141 | 5410 |volume | 2 |
| 190140 | 5410 |pages | 105-109 |
| 190139 | 5410 |authors | Onger, M., Jaluth, K. |
| 190144 | 5410 |publication_date | 17 January 2016 |
| 190136 | 5410 |journals | Nature Medicine |
| 190135 | 5410 |link_to_pubmed | |
| | | | |
+---------+---------+-------------------+-----------------------+
The code i have used is very similar as the one described here and can be seen below
$metadata = implode(', ', array_shift($publications));
foreach($publications as $publication){
foreach ($publication as $key => $metadata){
$key = array_keys($publication);
//$publication[$key];
}
$new_metadata[] = "(" . implode(', ', $publication) . ")";
}
how do i get the key and values?