Bird
0
0

Which of the following is the correct syntax to join array elements with a hyphen using implode?

easy📝 Syntax Q3 of 15
PHP - String Functions
Which of the following is the correct syntax to join array elements with a hyphen using implode?
Aimplode('-' $array);
Bimplode($array, -);
Cimplode($array - '-');
Dimplode('-', $array);
Step-by-Step Solution
Solution:
  1. Step 1: Recall correct implode syntax

    The correct syntax is implode(separator, array) or implode(array, separator) but the first form is preferred.
  2. Step 2: Check each option

    implode('-', $array); uses correct syntax with separator first and array second. Others have syntax errors or wrong argument order.
  3. Final Answer:

    implode('-', $array); -> Option D
  4. Quick Check:

    Correct implode syntax = implode(separator, array) [OK]
Quick Trick: Use implode(separator, array) syntax [OK]
Common Mistakes:
  • Swapping arguments order
  • Missing commas
  • Using invalid operators

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes