📲 Download Utility Tools Apps

EMI Calculator

Download EMI Calculator

SOA Games

Download SOA Games

SOA Technology App

Download SOA Technology

BMI Checker

Download BMI Checker

Task Jira

Download Task Jira

Laughing Adda

Download Laughing Adda

📅 हिंदी कैलेंडर ऐप डाउनलोड करें

Download Shubhcalendar App

complete PHP Arrays Practical Coding Test Paper

📝 PHP Practical Exam – Arrays

📌 Subject: PHP Programming

⏱ Time: 2 Hours

🎯 Total Marks: 50


✅ Section A: Basic Programs (10 Marks)

🔹 Q1 (5 Marks)

Create an indexed array of 5 numbers.

  • Print all elements
  • Print the sum of all numbers

🔹 Q2 (5 Marks)

Create an array of 5 fruits and display them using a for loop.


✅ Section B: Associative Arrays (10 Marks)

🔹 Q3 (5 Marks)

Create an associative array for a student:
(name, age, course)

  • Print all details using foreach

🔹 Q4 (5 Marks)

Create an associative array of subjects and marks.

  • Find and display the highest marks

✅ Section C: Multidimensional Arrays (10 Marks)

🔹 Q5 (5 Marks)

Create a multidimensional array of 3 students:
(name, age, course)

  • Print all student names

🔹 Q6 (5 Marks)

Display student data in this format:

Aditya - BCA  
Rahul - BSc
Neha - MCA

✅ Section D: Array Functions (10 Marks)

🔹 Q7 (5 Marks)

Create an array of numbers:

  • Sort in ascending order
  • Sort in descending order

🔹 Q8 (5 Marks)

Merge two arrays and display the result.


✅ Section E: Logic-Based Questions (10 Marks)

🔹 Q9 (5 Marks)

Create an array of numbers.

  • Use array_filter() to display only even numbers

🔹 Q10 (5 Marks)

Use array_map() to create a new array with square of numbers.


🚀 Bonus Question (Optional – 5 Marks)

🔹 Q11

Create a simple search system:

  • Store 5 names in an array
  • Take user input
  • Check if name exists or not

🎯 Marking Scheme

SectionMarks
A10
B10
C10
D10
E10
Bonus+5

💡 Instructions for Students

  • Write clean and readable code
  • Use proper syntax
  • Output must be displayed clearly
  • Use comments where necessary

Full Answer Key (Solutions) – PHP Arrays Practical Exam

📝 ✅ Section A: Basic Programs

🔹 Q1 Solution

$numbers = [10, 20, 30, 40, 50];// Print elements
foreach ($numbers as $num) {
echo $num . " ";
}// Sum
$sum = array_sum($numbers);
echo "<br>Sum: " . $sum;

🔹 Q2 Solution

$fruits = ["Apple", "Banana", "Mango", "Orange", "Grapes"];for ($i = 0; $i < count($fruits); $i++) {
echo $fruits[$i] . "<br>";
}

📝 ✅ Section B: Associative Arrays

🔹 Q3 Solution

$student = [
"name" => "Aditya",
"age" => 22,
"course" => "BCA"
];foreach ($student as $key => $value) {
echo "$key: $value <br>";
}

🔹 Q4 Solution

$marks = [
"Math" => 80,
"Science" => 90,
"English" => 75
];$max = max($marks);
echo "Highest Marks: " . $max;

📝 ✅ Section C: Multidimensional Arrays

🔹 Q5 Solution

$students = [
["Aditya", 22, "BCA"],
["Rahul", 21, "BSc"],
["Neha", 23, "MCA"]
];foreach ($students as $student) {
echo $student[0] . "<br>";
}

🔹 Q6 Solution

$students = [
["Aditya", 22, "BCA"],
["Rahul", 21, "BSc"],
["Neha", 23, "MCA"]
];foreach ($students as $student) {
echo $student[0] . " - " . $student[2] . "<br>";
}

📝 ✅ Section D: Array Functions

🔹 Q7 Solution

$numbers = [5, 2, 9, 1, 7];// Ascending
sort($numbers);
echo "Ascending: ";
print_r($numbers);// Descending
rsort($numbers);
echo "<br>Descending: ";
print_r($numbers);

🔹 Q8 Solution

$a = ["Red", "Blue"];
$b = ["Green", "Yellow"];$result = array_merge($a, $b);
print_r($result);

📝 ✅ Section E: Logic-Based Questions

🔹 Q9 Solution

$numbers = [1, 2, 3, 4, 5, 6];$even = array_filter($numbers, function($n) {
return $n % 2 == 0;
});print_r($even);

🔹 Q10 Solution

$numbers = [1, 2, 3, 4];$square = array_map(function($n) {
return $n * $n;
}, $numbers);print_r($square);

🚀 ✅ Bonus Solution

🔹 Q11 Solution (Search System)

$names = ["Aditya", "Rahul", "Neha", "Amit", "Priya"];$search = "Rahul"; // You can take user input hereif (in_array($search, $names)) {
echo "Name found!";
} else {
echo "Name not found!";
}

🎯 Extra Improvement (Advanced Version)

👉 With user input:

$names = ["Aditya", "Rahul", "Neha", "Amit", "Priya"];$search = $_GET['name'];if (in_array($search, $names)) {
echo "Name found!";
} else {
echo "Name not found!";
}


AI Spiritual Tools & Interactive Experiences

Explore powerful AI-driven tools for daily guidance, spirituality, fun quizzes, and self-discovery.

Today’s Quote

Get inspiring daily quotes powered by AI to motivate and guide your day.

Explore Now

AI Tarot Card Reader

Reveal insights about your future, love, and career with AI tarot readings.

Read Tarot

Love Match Calculator

Check compatibility and love predictions using AI-based analysis.

Check Match

Fortune Cookie

Open an AI fortune cookie and receive wisdom, luck, and fun messages.

Open Cookie

Quiz Categories

Engage with knowledge-based and fun quizzes across multiple categories.

Start Quiz

Panchang Calendar

View daily Panchang, auspicious timings, tithi, nakshatra, and festivals.

View Panchang

Online Numerology

Discover your destiny number, life path, and numerology predictions.

Calculate Now

Spiritual Feeds

Stay connected with spiritual thoughts, mantras, and divine content.

View Feeds

Quiz Hub

Attempt trending quizzes on GK, spirituality, festivals, and more.

Explore Quizzes