Goto main content

str_replace

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

STR_REPLACE

NAME

str_replace - Replace all occurrences of the search string with the replacement string.

SYNOPSIS

str_replace(search,replace,subject)

PARAMETERS

search
The value being searched for, otherwise known as the needle. An array may be used to designate multiple needles.
replace
The replacement value that replaces found search values. An array may be used to designate multiple replacements.
subject
The string being searched and replaced on, otherwise known as the haystack.

RETURN

This function returns a string with the replaced values.

EXAMPLES

in:  res={{str_replace(["ONE","TWO","THREE"],["TWO WORDS","MANY LETTERS","OTHER IDEAS"],"ONE SAMPLE")}}.
out: res=MANY LETTERS WORDS SAMPLE.

in:  res={{str_replace(["ONE","TWO","THREE"],"test","ONE TWO SAMPLES")}}.
out: res=test test SAMPLES.

in:  res={{str_replace("ONE","test","ONE TWO SAMPLES")}}.
out: res=test TWO SAMPLES.

SEE ALSO

{{ include("includes/strings.sn") }}

AUTHOR

Written by Pusnei Sergey, <sergey@sednove.com>

MODIFICATIONS

1.0 2014-09-09 21:24:14 laplante@sednove.com

Edit

© 2024 extenso Inc. All rights reserved.