Bird
0
0

You want to case-sensitively replace multiple different words in a string at once. Which PHP function allows replacing arrays of search and replace values simultaneously?

hard📝 Application Q8 of 15
PHP - String Functions
You want to case-sensitively replace multiple different words in a string at once. Which PHP function allows replacing arrays of search and replace values simultaneously?
Asubstr_replace()
Bstrtr()
Cstr_replace()
Dstr_ireplace()
Step-by-Step Solution
Solution:
  1. Step 1: Recall str_replace() supports arrays

    str_replace() can accept arrays for search and replace parameters to replace multiple values at once.
  2. Step 2: Compare with other functions

    substr_replace() replaces by position, strtr() can replace multiple but with different syntax, str_ireplace() is case-insensitive replace, str_repeat() repeats a string.
  3. Final Answer:

    str_replace() -> Option C
  4. Quick Check:

    Multiple replacements = str_replace() [OK]
Quick Trick: Use str_replace() with arrays for multiple replacements [OK]
Common Mistakes:
  • Using substr_replace() for multiple words
  • Confusing strtr() syntax
  • Ignoring case sensitivity when needed

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes