Bird
0
0

What is the primary effect of using the PHP function array_unique() on an array?

easy📝 Conceptual Q1 of 15
PHP - Array Functions
What is the primary effect of using the PHP function array_unique() on an array?
AIt removes duplicate values, keeping only the first occurrence of each value.
BIt sorts the array in ascending order.
CIt reverses the order of the array elements.
DIt converts all values to strings.
Step-by-Step Solution
Solution:
  1. Step 1: Understand array_unique()

    The function scans the array and removes any duplicate values.
  2. Step 2: Retain first occurrences

    Only the first instance of each value is kept; subsequent duplicates are removed.
  3. Final Answer:

    It removes duplicate values, keeping only the first occurrence of each value. -> Option A
  4. Quick Check:

    Check if duplicates remain after applying array_unique() [OK]
Quick Trick: array_unique() removes duplicates, keeps first occurrence [OK]
Common Mistakes:
  • Thinking it sorts the array
  • Assuming it removes keys instead of values
  • Believing it converts values to strings

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes