Bird
0
0

What happens if the delimiter passed to explode() does not exist in the string?

hard📝 Conceptual Q10 of 15
PHP - String Functions
What happens if the delimiter passed to explode() does not exist in the string?
AThe entire string is returned as a single-element array
Bexplode() returns an empty array
Cexplode() throws an error
Dexplode() returns null
Step-by-Step Solution
Solution:
  1. Step 1: Understand explode() behavior with missing delimiter

    If delimiter is not found, explode() returns array with original string as only element.
  2. Step 2: Confirm no error or empty array occurs

    explode() does not error or return empty array in this case.
  3. Final Answer:

    The entire string is returned as a single-element array -> Option A
  4. Quick Check:

    No delimiter found = single-element array [OK]
Quick Trick: No delimiter found? explode returns whole string in array [OK]
Common Mistakes:
  • Expecting empty array
  • Expecting error
  • Confusing with null return

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes