hphp/hack/manual/hsl/Functions/HH.Lib.Str/replace_every_nonrecursive.md
:::info[Note] This is a point-in-time snapshot of the API documentation from January 2026. Going forward, we will not be maintaining a public copy of these references, and recommend users to refer to the built-in signature helpers available in the Hack LSP instead for complete and up-to-date information. :::
Returns the "haystack" string with all occurrences of the keys of
$replacements replaced by the corresponding values
namespace HH\Lib\Str;
function replace_every_nonrecursive(
string $haystack,
KeyedContainer<string, string> $replacements,
): string;
Once a substring has been replaced, its new value will not be searched again.
If there are multiple overlapping matches, the match occuring earlier in
$haystack takes precedence. If a replacer is a prefix of another (like
"car" and "carpet"), the longer one (carpet) takes precedence. The ordering
of $replacements therefore doesn't matter.
Str\replace_every().string $haystackKeyedContainer<string,string> $replacementsstring