Multi-dimensional array warehouse receiving

Source: Internet
Author: User
Print_r ($ dbinsert:


Array
(
[0] => Array
(
[Apmac] => 0q: 4e: cb: 00: 01: 09
[Pub_ip] => 11.24.24.7
[Priv_ip] => 12.18.1.3
[Hwver] => VA500
[Fwver] => 69.0.0
[Vsmip] => 12.25.1.19
[Conntime] = & gt; 677822
[Boottime] = & gt; 49950
[State] =>
[Statetime] =>
[Hostname] => name1
[Location] => 0004.003.01
[Admin_id] => 0
)

[1] => Array
(
[Apmac] => 10: qe: cv: 02: 00: 37
[Pub_ip] => 11.24.24.7
[Priv_ip] => 12.18.1.3
[Hwver] => VA500
[Fwver] => 69.0.0
[Vsmip] => 12.25.1.19
[Conntime] = & gt; 169547
[Boottime] = & gt; 403315
[State] =>
[Statetime] =>
[Hostname] => nam2
[Location] => 0004.003.01
[Admin_id] => 0
)

[2] => Array
(
[Apmac] => r0: ve: cb: 00: ff: 04
[Pub_ip] => 13.24.28.7
[Priv_ip] => 92.18.1.18
[Hwver] => V
[Fwver] => 6 .)
[Vsmip] => 12.25.1.79
[Conntime] = & gt; 168
[Boottime] = & gt; 144497
[State] =>
[Statetime] =>
[Hostname] => name5
[Location] => 0004.003.01
[Admin_id] => 0
)

)



Problem:

I want to insert the content into table 3 of the database table. the table structure is the same as the returned content and the order is the same.

How can I write a php program?


Reply to discussion (solution)

$ F = ''; $ v = array () foreach ($ dbinsert as $ row) {if (empty ($ f) $ f = join (',', $ array_key ($ row); $ v [] = "('". join ("','", $ row ). "')";} $ SQL = "insert into table3 ($ f) values ". join (',', $ v); // execute the $ SQL statement.

$ F = ''; $ v = array () foreach ($ dbinsert as $ row) {if (empty ($ f) $ f = join (',', $ array_key ($ row); $ v [] = "('". join ("','", $ row ). "')";} $ SQL = "insert into table3 ($ f) values ". join (',', $ v); // execute the $ SQL statement.



Sorry .... Is it easy to write popular data without considering efficiency and introduction?

1. traverse the two-dimensional array and combine the elements in the array into a string (using a number in the middle) to form an inset string.
I don't understand this?

2. combine the above strings and SQL statements into inset statements and add them cyclically.

The version is awesome. I just want to translate it.

Notice: Undefined variable: array_key in Dex3.php on line 19 Fatal error: Function name must be a string in Dex3.php on line 19


19 if (empty ($ f) $ f = join (',', $ array_key ($ row ));

If (empty ($ f) $ f = join (',', array_keys ($ row ));

1. traverse the two-dimensional array and combine the elements in the array into a string (using a number in the middle) to form an inset string.
I don't understand this?

2. combine the above strings and SQL statements into inset statements and add them cyclically.

The version is awesome. I just want to translate it.

It's really a third brother, smart

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.