Posts

array within associative array computers example

<?php $index=0; $ computers =array( "computer1"=> array ("hdd"=>"400Gb","status"=>"working"), "computer2"=>array("hdd"=>"100GB","status"=>"Not working"), "computer3"=>array("hdd"=>"300Gb","status"=>"working"), "computer4"=>array("hdd"=>"1TB","status"=>"Not working") ); //print_r($computers); foreach($ computers as $comkey => $ comarray ) { echo $ comarray ["hdd"]." "; echo $ comarray ["status"]." "; echo "<br />"; } // output 400Gb    working 100GB   Not working 300Gb    working 1TB        Not working

assoaciative array with column sum associative array

 <?php $attendance=array( array("month"=>"june", "present_days"=>"13","pdays"=>"20"), array("month"=>"july", "present_days"=>"16","pdays"=>"20"), array("month"=>"aug", "present_days"=>"11","pdays"=>"20"), array("month"=>"sept", "present_days"=>"20","pdays"=>"20") ); $attendance_count=count($attendance); echo $attendance_count; // o/p 4 echo "<br />"; ?> <?php $present_days=null; $absent_days=null; $total_days=null; $total_marks=null; $total_absent_days=null; $total_present_days=null; for($i=0;$i<$attendance_count;$i++) { echo $attendance[$i]["month"]." "; echo $attendance[$i]["present_days"]." "; $total_present_days=$total_present_days+$a...

assosiative array

<?php $attendance=array(   array(" month "=>"june", " present_days "=>"13"," pdays "=>"20"), array(" month "=>"july", " present_days "=>"16"," pdays "=>"20"), array(" month "=>"aug", " present_days "=>"11"," pdays "=>"20"), array(" month "=>"sept", " present_days "=>"20"," pdays "=>"20") ); $ attendance_count = count ($attendance); echo $attendance_count; // o/p 4 echo "<br />"; ?> <?php for($i=0;$i< $attendance_count ;$i++) {        echo $attendance[$ i ][" month "]." "; } ?> o/p  4 june july aug sept

php 7.2

  Example 1: Given below is an email of a student’s result Name: Peter Watson Date of birth: 16-07-2001 age: 19 Roll no: 21 Subject Obtained Marks Total Marks Percentage English Grammar 63 80 78.75% Mathematics 70 80 87.5% Geography 52 80 65% Science 59 80 73.75% History 69 80 86.25% Economics 77 80 96.25% Art 55 80 68.75% Music 66 80 82.5% Total 511 640 79.84%   Code: //code before <html> <?php     $fname = "Peter" ;     $lname = "Watson" ;     $dob = "16-07-2001" ;     $roll_no = 21 ;     $student_marks = array (                  array ( "subject" => "English Grammar" , "obtained_marks" => 63 , "total_marks" => 80 ),                  array ( "subject" => "Mathematics" , "obtained_marks" =...