0
0
PHPprogramming~5 mins

Implode and join in PHP - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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'])?
A"a-b-c"
B"abc"
C"a,b,c"
D"a b c"
Which function is an alias of implode() in PHP?
Aexplode()
Bconcat()
Cjoin()
Dsplit()
What does implode() return when given an empty array?
Aempty string ""
Bfalse
Cnull
Darray
What is the default separator if none is provided to implode()?
Acomma
Bempty string
Cspace
Dsemicolon
Which of these is a correct way to join array elements with a space using implode()?
Aimplode($array, ' ')
Bimplode($array)
Cjoin($array, ' ')
Dimplode(' ', $array)
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.