I do this to query all data from the database
$query=$this->db->get('tablename', $num, $offset);
I would like to add “string “.$iteratorNumber (that is string1, string2,etc) as a new element in the value array.
I have also tried this
$query=$this->db->get('tablename', $num, $offset);
$query=$query->row_array();
$i=0;
foreach($query as $row)
{
array_push($row,"string".i++);
}
But this doesn’t do what I want it to.
UPDATE
The result looks like this
$data = array(
array('Name', 'Color', 'Size'),
array('Fred', 'Blue', 'Small'),
array('Mary', 'Red', 'Large'),
array('John', 'Green', 'Medium')
);
and I would like to then acquire
$data = array(
array('Name', 'Color', 'Size',''),
array('Fred', 'Blue', 'Small','something'),
array('Mary', 'Red', 'Large','something'),
array('John', 'Green', 'Medium','something')
);
Why not just do:
Then a new element is added? – If it is an array, you could just do:
Other than the above, I can’t think what you can do without seeing even more of your code – but it does add extra data to your outputted array from the database.
Update
Maybe I see what you mean now… you want to add ‘string X’ (where X is the nth entry) as many times as there are rows, so the following should do it (note your question is very nearly there!), but I’d personally make a copy of the array before hand.