Tuesday, 16 April 2019

Add Elements to Multi-Dimensional Array in PHP

Here we have $student array which is of course a multi-dimensional array. The array contains  the names of student each of which holds the Subject and Certificate array. We are going to add a completely new element which will contain the sum of mark scored of each student. 
So this is how adding array to multi-dimensional array

$students=[
    'Kima'=>[
        'SUBJECT'=>[
            'English'=>52,
            'Maths'=>33,
            'Science'=>44
        ],
        'CERTIFICATES'=>[ 'TFC'=>true,'TTM'=>false ]
        ],
    'Zaua'=>[
        'SUBJECT'=>[
            'English'=>60,
            'Maths'=>50,
            'Science'=>60
        ],
        'CERTIFICATES'=>['TFC'=>false,'TTM'=>true]
        ],
    'Lawma'=>[
        'SUBJECT'=>[
            'English'=>41,
            'Maths'=>79,
            'Science'=>40
        ],
        'CERTIFICATES'=>['TFC'=>false,'TTM'=>false]
    ],
    'Pari'=>[
        'SUBJECT'=>[
            'English'=>55,
            'Maths'=>43,
            'Science'=>53
        ],
        'CERTIFICATES'=>['TFC'=>false,'TTM'=>true]
    ]
];







We will create a empty array $marktotal and loop through the student array

$marktotal = [];
foreach($students as $k=>$v){
    //store the sum of mark scored in each subject to $marktotal
    //$k is the name of the student, we use it here as the key for the new $marktotal array,
    $marktotal[$k] = array_sum($v['SUBJECT']);
}


Loop the students array again to add the new element (Which is array).
 
foreach($students as $hming=>$course){

   //Check if the name of students exist in $marktotal key
    if(array_key_exists($hming, $
marktotal) ){
        //Create a new key 'TOTAL'
        //To get the actual mark total, we used the $hming as the $marktotal key and store it to the new key of $course
        $course['TOTAL'] = $marktotal[$hming];
    }

    //Since we do not want to modify the first array.
    $students[$hming] = $course;
}

print_r($students);



 

Friday, 25 January 2019

MIZO ṬAWNGA Ṭ LEH ₹ ZIAK DAN

Facebook group lamah post ka siam tawh tho nain kan ziah chipchiar em em loh vangin blog lamah hian kimchang deuh zawkin leh symbol ziak dan kan sawi ang. MS Office Word, Excel leh Pagemaker te hi Mizoramah chuan kan software hman nasat ber pawl te an ni a. Mizo Ṭawngah hian Ṭ ṭ hawrawp kan nei a. Tun hnaiah Indian Rupee kan ziah dan thin Rs/Re chu a symbol thar a lo pian tak avangin hi application kan sawi tak leh a dangah pawh hman hi a lo mawiin zawm ngei pawh tam tak chuan kan duh a ni.

Adobe PageMaker
Pagemaker hi DTP software hlui tawh tak a ni a. Mahse kan la thlak thei meuh lo. A thlakna tura an siam Adobe Indesign hi a ritin hman a har deuh te pawh a ni mah na. ₹ leh Ṭ te hi Unicode Character an ni a, an pianna a lo rei lutuk loh vangin Pagemaker chuan a support ve hman lo, a support hmain Pagemaker Support hi a thi hman a ni. Pagemaker-ah chuan Unicode hi 1-255 thleng chiah kan hmang thei a ni. Chuvangin dan pangai ang chuan Pagemaker-ah hian hman theih loh ve ve ang an ni. A hman theih dan awm chhun ber chu leh awmna hawrawp hman mai a ni. bik hi

tang hian download tur a awm a, VNT Font hmang hian Pagemaker-ah Ṭ kan chhu ve thei a ni. Rupee Symbol chu https://www.wfonts.com/font/rupee-foradian tang hian download theih a ni a. a font hming hi Rupee Foradian a ni. A unicode character hi kan hmang duh a nih chuan Pagemaker ni lovin Pagemaker ang chiah kawng engkima changkang leh tha zawk Adobe Indesign hman mai tur a ni. Indesign-ah chuan Alt+07788 hi hawrawp a ni a, hawrawp te chu Alt+07789 a ni thung ang.

Microsoft Word
Word bikah hian 2000 hnu lam version tangin Unicode Character support tan a ni a. A hma lam version-ah chuan Pagemaker ang bawkin chhutna a awm lo va, a hawrawp (font) hman mai a ngai a ni. Office 2000 hnu lamah erawh chuan chhut dan chihnih chithum lai a awm thei a. A hnuaia mi ang hian:
Microsoft Word hawng la:
(hawrawp pui) chhut nân 1E6C type phawt la, i type zawhah Alt leh X kha a rualin hmet rawh
(hawrawp te) chhut nân 1E6D type phawt la, i type zawhah Alt leh X kha a rualin hmet rawh.
Chhut dan dang leh awlsam zawk chu
Alt+07788 (hawrawpte Ṭ)
Alt+07789 (hawrawpte ṭ)

Rupee Symbol bik chhut nân
Alt+08377 (₹) emaw 20B9 chhut phawt a, Alt+X hmehin
Note: Wordpad, MS Powerpoint, MS Publisher leh MS OneNote-ah te a chunga kan sawi te hi a hman theih bawk.

Microsoft Excel
Word-a kan sawi ang tho hian Office 2000 tangin support tan a ni a. Mahse Word angin Excel-ah hi chuan a pawng chhut ngawt theih loh va, copy paste hmanga dah a ngai tlangpui a. Mahse Office 2013 tang khan unichar() formula an dah thar a hemi hmang hian chhut ve theih a ni ta. A hnuaia mi ang hian:
chhu tur chuan kan chhutluh duhna cell-ah =unichar(7788) chhuta enter hmeh tur a ni.
Ṭingṭang tih i chhu duh a nih chuan 
=UNICHAR(7788)&"ing"&UNICHAR(7789)&"ang" 
tih deuh duah a ngai a nih ber chu. 
Rupee Symbol chhut dawn pawhin a chunga formula hmang tho hian:
=UNICHAR(8377)
A duh tan chuan Excel auto correct option feature hmangin kan symbol chhut tur te hi duan lawk theih a ni a, mahse space tel lovin auto correct hi activate theih a nih loh vangin space hman a ngai zel thin a. Hêng symbol te hi kan hman nasat lem loh bawk avangin kan tarlang ta lo.