Version: v0.7.1 - Beta.  We welcome contributors & feedback.

String.replaceChars

replaceChars($fromChars, $toChars) -> string

Description

Do a one-for-one replacement of characters.

If the length of $fromChars and $toChars are different, the extra characters in the longer string will be ignored.

Note: To convert accented characters to ASCII, see removeAccents.

$s = 'Hello <FIRST-NAME>'

$s.replaceChars('<>-', '{}_')
//= 'Hello {FIRST_NAME}'

See Also