Recall & Review
beginner
What does the
implode() function do in PHP?The
implode() function joins array elements into a single string using a specified separator.Click to reveal answer
beginner
Is
join() different from implode() in PHP?No,
join() is an alias of implode(). Both do the same thing: join array elements into a string.Click to reveal answer
beginner
How do you use
implode() to join array elements with a comma?Use
implode(",", $array). This joins all elements of $array separated by commas.Click to reveal answer
beginner
What happens if you call
implode() with an empty array?It returns an empty string because there are no elements to join.
Click to reveal answer
intermediate
Can
implode() be used without specifying a separator?Yes, if you omit the separator, PHP uses an empty string as default, joining elements directly without anything between them.
Click to reveal answer
What is the output of
implode('-', ['a', 'b', 'c'])?✗ Incorrect
The
implode() function joins array elements with the given separator, here a dash '-'.Which function is an alias of
implode() in PHP?✗ Incorrect
join() is an alias of implode(), both join array elements into a string.What does
implode() return when given an empty array?✗ Incorrect
When the array is empty,
implode() returns an empty string.What is the default separator if none is provided to
implode()?✗ Incorrect
If no separator is given,
implode() uses an empty string to join elements.Which of these is a correct way to join array elements with a space using
implode()?✗ Incorrect
The correct syntax is
implode(' ', $array) where the first argument is the separator.Explain how
implode() works and give an example of joining an array with commas.Think about how you combine words with commas in a sentence.
You got /4 concepts.
Describe the relationship between
implode() and join() in PHP.They are like two names for the same thing.
You got /4 concepts.