Bird
0
0

Given $input = " 123abc123 ", which code removes digits only from both ends but keeps letters and spaces inside?

hard📝 Application Q9 of 15
PHP - String Functions
Given $input = " 123abc123 ", which code removes digits only from both ends but keeps letters and spaces inside?
Atrim($input, "0123456789")
Btrim($input, " ")
Crtrim($input, "123")
Dltrim($input, "abc")
Step-by-Step Solution
Solution:
  1. Step 1: Understand the goal

    Remove digits from both ends only, keep letters and spaces inside.
  2. Step 2: Analyze trim() with digit mask

    trim() with "0123456789" removes digits from both ends.
  3. Step 3: Check other options

    trim($input, " ") removes spaces only, rtrim() and ltrim() remove from one side and with wrong chars.
  4. Final Answer:

    trim($input, "0123456789") -> Option A
  5. Quick Check:

    trim() with digits removes digits ends [OK]
Quick Trick: Use trim() with digits string to remove digits ends [OK]
Common Mistakes:
  • Using trim() with space only
  • Using ltrim() or rtrim() incorrectly
  • Removing letters accidentally

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes