Bird
0
0

What is the output of this PHP code?

medium📝 Predict Output Q4 of 15
PHP - String Functions
What is the output of this PHP code?
$arr = ['red', 'green', 'blue'];
echo implode('|', $arr);
Ared|green|blue
Bred,green,blue
Credgreenblue
DArray
Step-by-Step Solution
Solution:
  1. Step 1: Understand implode with '|' separator

    The function joins array elements inserting '|' between each element.
  2. Step 2: Join elements

    Joining 'red', 'green', 'blue' with '|' results in 'red|green|blue'.
  3. Final Answer:

    red|green|blue -> Option A
  4. Quick Check:

    implode('|', array) = 'red|green|blue' [OK]
Quick Trick: implode inserts separator between array elements [OK]
Common Mistakes:
  • Expecting commas instead of '|'
  • Printing 'Array' instead of string
  • Missing separator in output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes