str_ireplace
-
All replacements in Ruby are done using
String#gsub. This method does both regular expression and string based replacements. To perform case insensitive replacements in Ruby, we need to use regular expressions with the case insensitive (i) modifier.PHP
$result = str_ireplace('hello', 'Hi', 'Hello world'); var_export($result); // => 'Hi world'
Ruby
p "Hello world".gsub(/hello/i, "Hi") # => "Hi world"
see also
Looking for Rails or PHP web application development, integration, and training?
Rails for PHP is brought to you by Maintainable Software. Get custom web applications and personalized training from the authors of the book and website.

