Bird
0
0

Which statement about array_walk is TRUE?

hard📝 Conceptual Q10 of 15
PHP - Array Functions
Which statement about array_walk is TRUE?
AIt requires the callback function to return the modified value
BIt always returns a new array with modified values
CIt cannot access the keys of the array elements
DIt modifies the original array only if the callback parameter is passed by reference
Step-by-Step Solution
Solution:
  1. Step 1: Understand array_walk behavior

    array_walk applies callback to each element; modification requires reference.
  2. Step 2: Evaluate other statements

    array_walk does not return a new array, can access keys, and callback return is ignored.
  3. Final Answer:

    It modifies the original array only if the callback parameter is passed by reference -> Option D
  4. Quick Check:

    Modification needs reference in callback [OK]
Quick Trick: Only reference parameters in callback modify original array [OK]
Common Mistakes:
  • Thinking array_walk returns a new array
  • Believing callback must return value
  • Assuming keys are inaccessible

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes