CodeIgniter Forums
array result - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: array result (/showthread.php?tid=40446)



array result - El Forum - 04-08-2011

[eluser]Aspi[/eluser]
Hello Forum members,

I get this array result, but this is not right for me
Code:
foreach($query->result_array() as $row){
$xml_data[] = $row;}
return $xml_data; ==> generate

Array
(
    [0] => Array
        (
            [partnertipusID] => 1
            [partnertipusnev] => A
        )

    [1] => Array
        (
            [partnertipusID] => 2
            [partnertipusnev] => B
        )

    [2] => Array
        (
            [partnertipusID] => 3
            [partnertipusnev] => C
        )

    [3] => Array
        (
            [partnertipusID] => 4
            [partnertipusnev] => D
        )

)

i would like get this format
Code:
Array
(
    [0] => Array
        (
            [0] => 1
            [1] => A
        )

    [1] => Array
        (
            [0] => 2
            [1] => B
        )

    [2] => Array
        (
            [0] => 3
            [1] => C
        )

    [3] => Array
        (
            [0] => 4
            [1] => D
        )

)

THX


array result - El Forum - 04-09-2011

[eluser]toopay[/eluser]
foreach($query->result_array() as $key => $val)
{
$xml_data[] = $val;
}


array result - El Forum - 04-09-2011

[eluser]toopay[/eluser]
I've just noticed that $row variable contains multi-dimensional array, so to get your stuff done, its should be...
Code:
foreach($query->result_array() as $row)
{
  $xml_data[] = array_values($row);
}



array result - El Forum - 04-09-2011

[eluser]Aspi[/eluser]
thank you