PHP: Case Insensitive String Replacements
Question by Guest | 2014-06-27 at 13:03
For searching and replacing strings, up to now I have always used the function str_replace in PHP.
Unfortunately, now I am coming to the limits of this function, because I would like to do some replacements independent from uppercase and lowercase writing of the letters and characters.
Of course, I also know about regular expressions and that you can use them in this case, but I am a PHP beginner so that this is a bit complicated for me at that time. Isn't there any simple way to do case insensitive string replacements in PHP?
Related Topics
How to Replace multiple Texts at the same Time
Tutorial | 0 Comments
PHP: Check Strings with Ctype-Functions for Character Classes
Article | 0 Comments
Java: Case Insensitive Equals - String Comparison
Info | 0 Comments
HTACCESS: Simplify URL
Tutorial | 0 Comments
PHP: Remove arbitrary Characters at the Beginning and the End of a String
Tutorial | 0 Comments
Android Programming: Receive Responce from HTTP POST Request
Tutorial | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
Instead of working with complicated regular expressions, you can also use the function str_ireplace instead of str_replace. This is a function working exactly like str_replace with the only difference is that it is replacing without caring about upper and lower case of writing.
It is even better for the performance and it is recommended to use this function instead of regular expressions (preg_replace() with the i-modifier).
2014-06-29 at 15:09