Bird
0
0

Which of the following is the correct syntax to remove characters "abc" from the right end of a string $str in PHP?

easy📝 Syntax Q3 of 15
PHP - String Functions
Which of the following is the correct syntax to remove characters "abc" from the right end of a string $str in PHP?
Artrim($str, "abc")
Btrim($str, "abc")
Cltrim($str, "abc")
Dstrip($str, "abc")
Step-by-Step Solution
Solution:
  1. Step 1: Understand the function parameters

    rtrim() takes a string and an optional character mask to remove from the right end.
  2. Step 2: Match the function and parameters

    To remove characters "abc" from the right, use rtrim($str, "abc").
  3. Final Answer:

    rtrim($str, "abc") -> Option A
  4. Quick Check:

    rtrim() with char mask removes from right [OK]
Quick Trick: rtrim() second argument is chars to remove [OK]
Common Mistakes:
  • Using trim() which removes from both ends
  • Using ltrim() which removes from left
  • Using non-existent strip() function

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes