Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7608043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:49:09+00:00 2026-05-31T00:49:09+00:00

if only one array is there for example $values = array(x, y, z); i

  • 0

if only one array is there for example

$values = array(x, y, z);

i am adding them into database like this

    foreach ($values as $value)
    {
        $insertFunction = addValues($value);
    }

my arrays:

$array1 = Array ( 1, 2, 1, 2, 1, 2, 1, 2, 1, 2 );

$array2 = Array ( fb1, or1, fb2, or2, fb3, or3, fb4, or4, fb5, or5 );

But i want both array to combine and insert them into database.
How can i do this please help me

Updated:

When i am printing the POST values i am getting out put like this

Array ( [0] => 1 [1] => 2 [2] => 1 [3] => 2 [4] => 1 [5] => 2 [6] => 1 [7] => 2 [8] => 1 [9] => 2 )

Array ( [0] => fb1 [1] => or1 [2] => fb2 [3] => or2 [4] => fb3 [5] => or3 [6] => fb4 [7] => or4 [8] => fb5 [9] => or5 )

when i tried with array_merge my out put is like this

Array ( [0] => 1 [1] => 2 [2] => 1 [3] => 2 [4] => 1 [5] => 2 [6] => 1 [7] => 2 [8] => 1 [9] => 2 [10] => fb1 [11] => or1 [12] => fb2 [13] => or2 [14] => fb3 [15] => or3 [16] => fb4 [17] => or4 [18] => fb5 [19] => or5 ) 

How to insert them in separate columns in a table $array1 and $array2

my database table is like this

1.id
2.username
3.network_id

id is primary key
network_id values coming in array1
username values coming in array2

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T00:49:10+00:00Added an answer on May 31, 2026 at 12:49 am

    EDIT:

    After you mentioned seperated columns I think I understand what you’re looking for:
    I’m assuming that array1 and array2 are in the same size.

    for($i = 0; $i < count($array1); $i++)
    {
    
      $array2[$i] = (int)$array2[$i]; //"validating" the username (an integer)
      mysql_query("INSERT INTO yourTableName (`username`,`network_id`) VALUES('".$array2[$i]."','".$array1[$i]."')");
    }
    

    Result:

    tblName:

    username: 1 2 1 …

    network_id: fb1 or1 fb2 …

    Is that what you were looking for?

    Ignore this and merging:

        $combined = array_merge($array1 , $array2);
    
       //$combined = Array ( 1, 2, 1, 2, 1, 2, 1, 2, 1, 2,fb1, or1, fb2, or2, fb3, or3, fb4, or4, fb5, or5 );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got an array of 10 frogs, and only one jumps. I want them
Why only one overload throws this exception? Little update: I understand that there was
How do you verify an array contains only values that are integers? I'd like
I found only one attempt to create such compiler - http://sourceforge.net/projects/xsltc/ . But this
I thought there was only one - included in jQuery UI and documented here
I like the idea of having only one return statement per method. What do
Given an array of N integer such that only one integer is repeated. Find
Is there a way of doing array_map but as an iterator? For example: foreach
I'm C++ begginer. I did this excercise from Deitel's book: Use a one-dimensional array
I have a URL of form http://www.example.com?foo=one&foo=two I want to get an array of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.