how to define multidimensional array in php for multiple records
Advert.
how to define multidimensional array in php for multiple records
Welcome Sueet to eTI comunity.
Your query has been approved.
For you question: I generally prefer following format:
Say you have 2 classes with 4 student each with 5 subject marks for each :
I hope that helps.Code:$arr_records = array( 'class1' => array( 'student1' => array( 'sub1' => 23, 'sub2' =>44, 'sub3' =>22, 'sub4' =>24, ), 'student2' => array( 'sub1' => 23, 'sub2' =>25, 'sub3' =>32, 'sub4' =>24, ), 'student3' => array( 'sub1' => 33, 'sub2' =>20, 'sub3' =>22, 'sub4' =>27, ), 'student4' => array( 'sub1' => 23, 'sub2' =>20, 'sub3' =>31, 'sub4' =>24, ), ), 'class1' => array( 'student1' => array( 'sub1' => 11, 'sub2' =>41, 'sub3' =>23, 'sub4' =>24, ), 'student2' => array( 'sub1' => 19, 'sub2' =>18, 'sub3' =>32, 'sub4' =>24, ), 'student3' => array( 'sub1' => 18, 'sub2' =>17, 'sub3' =>22, 'sub4' =>27, ), 'student4' => array( 'sub1' => 23, 'sub2' =>41, 'sub3' =>33, 'sub4' =>24, ), ), );
You may want to read:
Thought of the Moment:
A community is all about helping each other.