Replace all occurrences of the $search string with the $replacement string

string:replace(STRING $string, STRING $search, STRING $replacement, BOOL $case_sensitive=TRUE, INT $limit=0) : STRING

string:replace('hi there','hi','bye')
#=> "bye there"

string:replace('Hi there','hi','bye')
#=> "Hi there"

# case insensitive search and replace
string:replace('Hi there','hi','bye', FALSE)
#=> "bye there"

# note: you can set $limit to anything bigger than 0 to limit the number of items getting replaced
string:replace("hi hi hi", 'hi', 'bye', FALSE, 2)
#=> "bye bye hi"

Copyright ©2013-2022 SunSed®. All rights reserved.