Hi, Everybody I am getting ouput array from database in this structure: Array ( [0] => Array ( [MAIN_CODE] => MAINTEST1 [SUB_CODE] => SUBTEST1 [MAINCODE_STATUS] => N [SUBCODE_STATUS] => N [CODE_TEST] => YES ) [1] => Array ( [MAIN_CODE] => MAINTEST1 [SUB_CODE] => SUBTEST2 [MAINCODE_STATUS] => N [SUBCODE_STATUS] => N [CODE_TEST] => NO ) ) but I want the create output for above array into different array structure that below I mentioned: Array( [MAINTEST1] => Array( MAINCODE_STATUS => N SUBTEST1 => Array( SUBCODE_STATUS => N CODE_TEST => YES ) SUBTEST2 => Array( SUBCODE_STATUS => N CODE_TEST => NO ) ) ) Can anybody help me how create this array using PHP. Regards Tanmoy