KEMBAR78
Array in php | PPTX
Array in PHP
What is Array ?
• Array is used to store multiple values in a single
variable. It helps reducing the number of
variables in the code. In PHP we use 3 type array.
Types of Array
• 1. Numeric Array
• 2. Associative Array
• 3. Multi Dimensional Array
Numeric Array
• An array with numeric index.
$student = array(“abc”=>”123”, “xyz”, “ccc”);
for($x=0; $x < sizeof($student); $x++)
{
echo $student[$x].”<br>”;
}
Associative Array
• An array where each key is associated with a value.
• $student = array("xyz"=>"9/8”=>”123”,"abc"=>"3/12","zzz"=>"3/10");
• foreach($student as $x=>$y=>$z)
• {
• echo "$x is $y is $z<br>";
• }
Multi Dimensional Array
• An array contain one or more array.
$student=array("punjab"=>array("jalandhar","phagwara","ludhiana"),
"haryana" => array("ambala","hisar"));
• echo $student["punjab"][0];

Array in php

  • 1.
  • 2.
    What is Array? • Array is used to store multiple values in a single variable. It helps reducing the number of variables in the code. In PHP we use 3 type array.
  • 3.
    Types of Array •1. Numeric Array • 2. Associative Array • 3. Multi Dimensional Array
  • 4.
    Numeric Array • Anarray with numeric index. $student = array(“abc”=>”123”, “xyz”, “ccc”); for($x=0; $x < sizeof($student); $x++) { echo $student[$x].”<br>”; }
  • 5.
    Associative Array • Anarray where each key is associated with a value. • $student = array("xyz"=>"9/8”=>”123”,"abc"=>"3/12","zzz"=>"3/10"); • foreach($student as $x=>$y=>$z) • { • echo "$x is $y is $z<br>"; • }
  • 6.
    Multi Dimensional Array •An array contain one or more array. $student=array("punjab"=>array("jalandhar","phagwara","ludhiana"), "haryana" => array("ambala","hisar")); • echo $student["punjab"][0];