title: Creating array for use in CodeIgniter Activerecord input_batch
body: <p>I'm trying to do an array which is suitable for the Codeignitors input_batch activerecord. I'm quering a Link table so I have onlu two columns - user_id and group_id and because I'm gonna insert information only for a certain user the user_id is the same every time, and I need to change only the group_id.</p>
  
  <p>Here is what I've done:</p>
  
  <pre><code> $str = $dataGroups['groups'];
   preg_match_all('/[0-9]/', $str, $matches);
  </code></pre>
  
  <p>this part I just take the info for the groups which is in form of numbers displayed '1,2,3,4...' and take only the numbers which are the values of the foreign key 'group_id'</p>
  
  <p>After that all I do is creating the array that I'm gonna use for the input_batch record doing this:</p>
  
  <pre><code>$count = count($matches[0]);
    $datas = array();
  
      for ($i = 0; $i &lt; $count; ++$i)
      {
      $datas[] = array("user_id"=&gt;$data['id'],"group_id" =&gt; $matches[0][$i]);
      }
    return $datas;
  </code></pre>
  
  <p>here $data['id'] is the user_id and it should be the same for all elements.
  At the end I have to get the same structure as shown in the CI tutorial(I guess so at least) which is:</p>
  
  <pre><code>$data = array(
     array(
        'title' =&gt; 'My title' ,
        'name' =&gt; 'My Name' ,
        'date' =&gt; 'My date'
     ),
     array(
        'title' =&gt; 'Another title' ,
        'name' =&gt; 'Another Name' ,
        'date' =&gt; 'Another date'
     )
  );
  </code></pre>
  
  <p>(Haven;t modify it, I just quote it here), but when I var_dump($datas) I get null. So my logic is leaking somewhere.</p>
  
  <p>Thanks for help
  Leron</p>