Version: v0.8.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 toAscii.

$s = 'Hello <FIRST-NAME>'

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

See Also