Recall & Review
beginner
What does the
explode() function do in PHP?The
explode() function splits a string into an array using a specified delimiter.Click to reveal answer
beginner
How do you split a string by spaces using
explode()?Use
explode(' ', $string) to split the string at each space character.Click to reveal answer
intermediate
What is the difference between
explode() and str_split()?explode() splits a string by a delimiter into an array of substrings. <br>str_split() splits a string into an array of single characters or fixed-length chunks.Click to reveal answer
beginner
What will
explode(',', 'apple,banana,orange') return?It returns an array:
['apple', 'banana', 'orange'] splitting the string at each comma.Click to reveal answer
intermediate
Can
explode() handle an empty delimiter?No,
explode() requires a non-empty string as the delimiter. Passing an empty string will cause a warning.Click to reveal answer
Which function splits a string into an array by a delimiter in PHP?
✗ Incorrect
explode() splits strings by a delimiter. implode() joins array elements into a string.What does
explode('-', '2024-06-15') return?✗ Incorrect
The string is split at each dash, producing an array of three parts.
What happens if the delimiter is not found in the string when using
explode()?✗ Incorrect
If delimiter is missing,
explode() returns an array containing the whole string.Which function splits a string into single characters or fixed-length chunks?
✗ Incorrect
str_split() splits strings into characters or chunks, unlike explode() which uses delimiters.What is the correct way to split a CSV string into an array?
✗ Incorrect
CSV values are separated by commas, so use
explode(',', $csvString).Explain how the
explode() function works and give an example.Think about how you cut a sentence into words using spaces.
You got /4 concepts.
Describe the difference between
explode() and str_split() in PHP.One splits by a character or string, the other by length.
You got /3 concepts.