0% found this document useful (0 votes)
2 views

PRACTICAL 1

The document provides a PHP script demonstrating the use of indexed arrays, associative arrays, and multidimensional arrays. It includes examples of each type of array with output formatting, showcasing how to iterate through and display their contents. The script is part of a practical exercise for learning PHP array handling.

Uploaded by

patelsoham.797
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

PRACTICAL 1

The document provides a PHP script demonstrating the use of indexed arrays, associative arrays, and multidimensional arrays. It includes examples of each type of array with output formatting, showcasing how to iterate through and display their contents. The script is part of a practical exercise for learning PHP array handling.

Uploaded by

patelsoham.797
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Practical Set –2 Aim :- Write PHP Script to demostrate assosiative array.

Practical-1

Program :-
<?php
echo"<h1>Indexed Array</h1>";
$car=array("BMW","Toyota","Volvo");
$n = count($car);
for ($i= 0; $i < $n; $i++)
{
echo$car[$i];
echo"<hr>";
}
echo"<h1>Assosiative array</h1>";
$cars=array("volvo"=>100,"bmw"=>200,"toyota"=>300);
$i=count($cars);
foreach($cars as $key=>$value){
echo $key . " = " . $value;
echo "<br>";
echo "<hr>";
}
var_dump($cars);
echo "<hr>";

echo"<h1>Multidimensional Array</h1>";
$students = array(
array("name" => "soham", "age" => 17, "grade" => "A+"),
array("name" => "vraj", "age" => 18, "grade" => "B+"),
array("name" => "masoom", "age" => 16, "grade" => "A"),
);
foreach ($students as $information) {
echo "<p>Name: " . $information["name"] . "</p>";
echo "<p>Age: " . $information["age"] . "</p>";
echo "<p>Grade: " . $information["grade"] . "</p>";

NAME:-PATEL SOHAM R. ER.NO : 23171371114 CLASS – IT C-3 Page 1


Practical Set –2 Aim :- Write PHP Script to demostrate assosiative array.
Practical-1

}
?>
Output :-

NAME:-PATEL SOHAM R. ER.NO : 23171371114 CLASS – IT C-3 Page 2

You might also like