5 Arrays write to database at the same time how to write?

Source: Internet
Author: User
$_post[' A '] value is 1,2,3,4,5
$_post[' B '] value is a,b,c,d,e
$_post[' C '] value is 6,7,8,9,0
$_post[' d '] value is h,i,j,k,l
$_post[' E '] value is o,p,q,r,s

These five arrays are also In the back. Now I'm going to write them all into the database, how should the loops be written? foreach appears to be only for an array.


The last write to the database format should be
First: 1 a 6 h i
Article II: 2 b 7 I P
Article three: 3 C 8 J Q
Fourth: 4 D 9 k R
Fifth: 5 e 0 L s


Reply to discussion (solution)

foreach ($_post[' a '] as $i = = $a) {  $b = $_post[' B '];  $d = $_post[' C ');  $d = $_post[' d '];  $e = $_post[' E '];  With $a, $b, $c, $d, $e related actions}

can also
foreach (Array_map (null, $_post[' a '], $_post[' B '), $_post[' C '], $_post[' d '], $_post[' e ']) as $r) {  //$r Related actions}

foreach ($_post[' a '] as $i = = $a) {  $b = $_post[' B '];  $d = $_post[' C ');  $d = $_post[' d '];  $e = $_post[' E '];  With $a, $b, $c, $d, $e related actions}

can also
foreach (Array_map (null, $_post[' a '], $_post[' B '), $_post[' C '], $_post[' d '], $_post[' e ']) as $r) {  //$r Related actions}




I have each column in the database corresponding to a column, this looks like a bad one to write

See what you got in the loop yourself.

  • 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.