strtr-from-php
v1.0.3
Published
TypeScript implementation of strtr from PHP
Downloads
19
Readme
strtr-from-php
This package is a TypeScript implementation of the strtr
function from PHP, replicates both from, to
and replace_pairs
modes exactly.
Install
npm i strtr-from-php
Usage
import { strtr } from 'strtr-from-php';
// Character-to-character replacement
strtr('abcdef', 'abc', 'xyz'); // 'xyzdef'
// Substring replacement
strtr('Hello World', {
Hello: 'X',
World: 'Planet',
}); // 'X Planet'
// Complex replacements
strtr('start middle end', {
start: 'begin',
middle: 'center',
end: 'stop',
'begin center stop': 'complete',
}); // 'begin center stop'
License
MIT License