📲 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

ready-to-use MCQ test on PHP Arrays

📝 PHP Arrays – MCQ Test

✅ Section A: Basic (Indexed Arrays)

🔹 Q1

Which function is used to count elements in an array?
A) size()
B) count()
C) length()
D) total()

👉 Answer: B


🔹 Q2

What is the index of the first element in PHP array?
A) 1
B) 0
C) -1
D) None

👉 Answer: B


🔹 Q3

What will this output?

$colors = ["Red", "Green", "Blue"];
echo $colors[1];

A) Red
B) Green
C) Blue
D) Error

👉 Answer: B


🔹 Q4

Which loop is commonly used for indexed arrays?
A) while
B) do-while
C) for
D) switch

👉 Answer: C


🔹 Q5

Which of the following creates an array?
A) $arr = ();
B) $arr = [];
C) $arr = {};
D) $arr = <>;

👉 Answer: B


✅ Section B: Associative Arrays

🔹 Q6

Associative arrays use:
A) Numbers as keys
B) Strings as keys
C) Both
D) None

👉 Answer: C


🔹 Q7

What will this output?

$student = ["name" => "Aditya", "age" => 22];
echo $student["name"];

A) 22
B) name
C) Aditya
D) Error

👉 Answer: C


🔹 Q8

Which loop is best for associative arrays?
A) for
B) foreach
C) while
D) switch

👉 Answer: B


🔹 Q9

Function to check if key exists in array:
A) isset()
B) array_key_exists()
C) key_exists()
D) Both B and C

👉 Answer: D


🔹 Q10

Which function sorts associative array by value?
A) sort()
B) ksort()
C) asort()
D) rsort()

👉 Answer: C


✅ Section C: Multidimensional Arrays

🔹 Q11

Multidimensional array means:
A) One value
B) Array inside array
C) Only numbers
D) Only strings

👉 Answer: B


🔹 Q12

Output of:

$data = [["A", "B"], ["C", "D"]];
echo $data[1][0];

A) A
B) B
C) C
D) D

👉 Answer: C


🔹 Q13

Which loop is best for multidimensional arrays?
A) Nested loop
B) Single loop
C) switch
D) goto

👉 Answer: A


✅ Section D: Array Functions

🔹 Q14

Which function sorts array in ascending order?
A) rsort()
B) sort()
C) asort()
D) ksort()

👉 Answer: B


🔹 Q15

Which function merges arrays?
A) combine()
B) array_merge()
C) join()
D) concat()

👉 Answer: B


🔹 Q16

Which function removes duplicates?
A) array_unique()
B) unique()
C) remove_dup()
D) array_clean()

👉 Answer: A


🔹 Q17

Which function filters array values?
A) array_map()
B) array_filter()
C) filter_array()
D) array_reduce()

👉 Answer: B


🔹 Q18

Which function modifies each element?
A) array_filter()
B) array_map()
C) array_sort()
D) array_merge()

👉 Answer: B


✅ Section E: Advanced

🔹 Q19

What will array_map() return?
A) Boolean
B) New array
C) Integer
D) String

👉 Answer: B


🔹 Q20

Which function sorts array by key?
A) sort()
B) asort()
C) ksort()
D) rsort()

👉 Answer: C




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