dreamwest Posted July 3, 2010 Share Posted July 3, 2010 Im trying to specify keys for associative arrays but ive never done it before other than via mysql This: $srt = 1; $end = 10; while ($srt < $end) { $arr[]= $srt; ++$srt; }//end while print_r ($arr); Outputs: (10 loops) Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 [8] => 9 ) But how can i get it like this: (1 loop example) Array ( [0] => Array ( [q_id] => 1 [q_v_id] => 857434 [q_session] => fe13c9e53d1e6d0170a59f88c6327547 ) ) Quote Link to comment Share on other sites More sharing options...
Psycho Posted July 3, 2010 Share Posted July 3, 2010 $theArray = array ( 0 => array ( 'q_id' => 1, 'q_v_id' => 857434, 'q_session' => fe13c9e53d1e6d0170a59f88c6327547 ) ); print_r($theArray); Quote Link to comment Share on other sites More sharing options...
dreamwest Posted July 3, 2010 Author Share Posted July 3, 2010 Thanks! I think i undestand it now $srt = 1; $end = 10; while ($srt < $end) { $arr[]= array('q_id' => $srt, 'field2' => barry, 'field3' => german) ; ++$srt; }//end while print_r ($arr); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.