title: Insert array into mysql table
body: <p>I have a csv file formatted as follows:</p>
  
  <pre><code>a;a1;1;0;1
  b;b1;1;0;0
  </code></pre>
  
  <p>And using a php script below I can convert it to this:</p>
  
  <pre><code>a;a1;1;
  a;a1;0;
  a;a1;1;
  b;b1;1;
  b;b1;0;
  b;b1;0;
  </code></pre>
  
  <p>Using this:</p>
  
  <pre><code>$data = array();
  foreach($lines as $value) {
      $value = explode(";", $value);
  
      $first = array_splice($value, 0, 2);
  
      foreach($value as $x){
          $row = $first;
          $row[] = $x;
          $data[] = implode(';', $row);
      }
  }
  </code></pre>
  
  <p>Where the output is an array:</p>
  
  <pre><code>array(6) {
    [0]=&gt;
    string(6) "a;a1;1"
    [1]=&gt;
    string(6) "a;a1;0"
    [2]=&gt;
    string(6) "a;a1;1"
    [3]=&gt;
    string(6) "b;b1;1"
    [4]=&gt;
    string(6) "b;b1;0"
    [5]=&gt;
    string(6) "b;b1;0"
  }
  </code></pre>
  
  <p>Now I'm trying to insert this array to a mysql table that I have set up, but I'm having trouble...</p>
  
  <pre><code>$file = "_ss.csv";
  $lines = file($file);
  $count = count($lines);
  $data = array();
  $i = 0;
  foreach($lines as $value){
      $value = explode(";", $value);
      $first = array_splice($value, 0, 2); 
  
      foreach($value as $x){
  
          $row = $first;
          $row[] = $x;
          $data[] = implode(',', $row);
          $dump = implode(',', $data);
          $query="INSERT INTO csv_test2 VALUES ('$dump')";
          $init=mysql_query($query);
  $i++;
  echo $dump;
  
      }
  }
  
  echo "&lt;pre&gt;";
  print_r($dump);
  echo "&lt;/pre&gt;";
  </code></pre>
  
  <p>Any ideas how to make it work?</p>