0
array(2) {
  [0]=>
  array(1) {
    ["url_id"]=>
    string(2) "45"
  }
  [1]=>
  array(1) {
    ["h"]=>
    string(1) "3"
  }
}

echo $column_list = join(',', $items);
...

This PDO Insert Array Using Key As Column Name helps me inserting array values in MySQL table easily. But now I do have an array containing subarrays and it looks like this join(',', $items); does not work. Guess you think "of course it doesn't work" right now, but how can I store the keys and the values into a variable to use $sql = "INSERT INTO applications ($column_list) VALUES ($param_list)"; successfully.

I have tried array_merge but that did not work at all. I would like to show some code examples, but I have no idea what to try and how to achieve that.

Thanks for your help! I appreciate it!

3
  • 1
    Get keys/values with a foreach Commented Sep 27, 2017 at 13:08
  • And save those in a new array? Commented Sep 27, 2017 at 13:10
  • look it up Commented Sep 28, 2017 at 13:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.