Bird
0
0

Which of the following is the correct way to call array_walk on an array $data using a callback function named processItem?

easy📝 Syntax Q3 of 15
PHP - Array Functions
Which of the following is the correct way to call array_walk on an array $data using a callback function named processItem?
Aarray_walk($data, 'processItem');
Barray_walk('processItem', $data);
Carray_walk($data, processItem());
Darray_walk(processItem, $data);
Step-by-Step Solution
Solution:
  1. Step 1: Understand array_walk syntax

    The correct syntax is array_walk(array, callback).
  2. Step 2: Identify correct callback usage

    The callback function name should be passed as a string without parentheses.
  3. Final Answer:

    array_walk($data, 'processItem'); -> Option A
  4. Quick Check:

    Callback as string, array first parameter [OK]
Quick Trick: Callback function name as string, array first [OK]
Common Mistakes:
  • Passing callback as a function call with parentheses
  • Swapping the order of parameters
  • Passing callback without quotes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes