0% found this document useful (0 votes)
3 views3 pages

Prac 4

The document contains practical exercises for programming in PHP, specifically focusing on different types of arrays: indexed, associative, and multidimensional. It includes code examples for each type of array, demonstrating how to create and manipulate them. The output for each code snippet is also mentioned, showcasing the results of the executed programs.

Uploaded by

Sumedh Raut
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)
3 views3 pages

Prac 4

The document contains practical exercises for programming in PHP, specifically focusing on different types of arrays: indexed, associative, and multidimensional. It includes code examples for each type of array, demonstrating how to create and manipulate them. The output for each code snippet is also mentioned, showcasing the results of the executed programs.

Uploaded by

Sumedh Raut
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/ 3

dd

NAME: SUMEDH SANJAY RAUT


CLASS: CO6I(A)
ROLL NO: 532
SUBJECT: WBP(22619)

PRACTICAL NO: 4

X.Develop a program to using Indexed array.


Code:
<?php
echo"<b>***Indexed Array In PHP***</b><br><br>";
$subject = array("WBP", "MAD", "Python", "AJP");

echo "Index[0] = ",$subject[0],'<br>';

echo "Index[1] = ",$subject[1],'<br>';

echo "Index[2] = ",$subject[2],'<br>';

echo "Index[3] = ",$subject[3];

?>
Output:
dd

XI. Exercise

1. Develop a program to using Associative array.


Code:
<?php
echo"<b>***Associative Arrays***</b><br><br>";
$marks = array("Sumedh" => 85, "Ashok" => 92, "Saurabh" => 78);

echo "Marks of Sumedh is: " . $marks['Sumedh'] . "<br>";


echo "Marks of Ashok is: " . $marks['Ashok'] . "<br>";
echo "Marks of Saurabh is: " . $marks['Saurabh'] . "<br><br>";

$marks["Sumedh"] = 90;
echo "Updated marks of Sumedh is: " . $marks['Sumedh'] ."<br><br>";

foreach ($marks as $student => $mark) {


echo "Student: " . $student . ", Marks: " . $mark . "<br>";
}
?>

Output:
dd

2. Develop a program to using Multidimensional array.


Code:
<?php
echo"<b>***Multidimensional Array***</b><br><br>";
$products = array(
array("Name" => "Laptop", "Price" => 50000, "Stock" => 10),
array("Name" => "Tablet", "Price" => 20000, "Stock" => 25),
array("Name" => "Smartphone", "Price" => 15000, "Stock" => 50)
);

foreach ($products as $product) {


echo "Product: " . $product["Name"] . "<br/>";
echo "Price: " . $product["Price"] . "<br/>";
echo "Stock: " . $product["Stock"] . "<br/><br/>";
}
?>
Output:

You might also like