Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to combine both array and insert into database php
    primarykey
    data
    text
    <p>if only one array is there for example</p> <pre><code>$values = array(x, y, z); </code></pre> <p>i am adding them into database like this</p> <pre><code> foreach ($values as $value) { $insertFunction = addValues($value); } </code></pre> <p>my arrays: </p> <pre><code>$array1 = Array ( 1, 2, 1, 2, 1, 2, 1, 2, 1, 2 ); $array2 = Array ( fb1, or1, fb2, or2, fb3, or3, fb4, or4, fb5, or5 ); </code></pre> <p>But i want both array to combine and insert them into database. How can i do this please help me</p> <p>Updated:</p> <p>When i am printing the POST values i am getting out put like this</p> <pre><code>Array ( [0] =&gt; 1 [1] =&gt; 2 [2] =&gt; 1 [3] =&gt; 2 [4] =&gt; 1 [5] =&gt; 2 [6] =&gt; 1 [7] =&gt; 2 [8] =&gt; 1 [9] =&gt; 2 ) Array ( [0] =&gt; fb1 [1] =&gt; or1 [2] =&gt; fb2 [3] =&gt; or2 [4] =&gt; fb3 [5] =&gt; or3 [6] =&gt; fb4 [7] =&gt; or4 [8] =&gt; fb5 [9] =&gt; or5 ) </code></pre> <p>when i tried with array_merge my out put is like this </p> <pre><code>Array ( [0] =&gt; 1 [1] =&gt; 2 [2] =&gt; 1 [3] =&gt; 2 [4] =&gt; 1 [5] =&gt; 2 [6] =&gt; 1 [7] =&gt; 2 [8] =&gt; 1 [9] =&gt; 2 [10] =&gt; fb1 [11] =&gt; or1 [12] =&gt; fb2 [13] =&gt; or2 [14] =&gt; fb3 [15] =&gt; or3 [16] =&gt; fb4 [17] =&gt; or4 [18] =&gt; fb5 [19] =&gt; or5 ) </code></pre> <p>How to insert them in separate columns in a table $array1 and $array2</p> <p>my database table is like this</p> <p>1.id 2.username 3.network_id </p> <p>id is primary key network_id values coming in array1 username values coming in array2</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload