Mysql results into array (PHP)

Posted by cthulhu on Stack Overflow See other posts from Stack Overflow or by cthulhu
Published on 2010-06-06T11:28:47Z Indexed on 2010/06/06 11:32 UTC
Read the original article Hit count: 317

Filed under:
|

How can i convert mysql results (from mysql_fetch_array) into such a form?

$some = array(
     "comments" => array(
         array( "text" => "hi", "id" => "1" ),
         array( "text" => "hi", "id" => "2" ),
         array( "text" => "hi", "id" => "3" ),
         array( "text" => "hi", "id" => "4" )
    )
);

while the db looks like:

comments

id  text
1   blabla bla
2   bla bla

i've tried to fetch the values with foreach/while and insert it into two arrays but no success...

© Stack Overflow or respective owner

Related posts about php

Related posts about arrays