Skip to content

Latest commit

 

History

History
16 lines (12 loc) · 336 Bytes

str-replace.md

File metadata and controls

16 lines (12 loc) · 336 Bytes

strtr

str::replace() alternative

It's nice to be able to search replace with key/value pair. The toolkit does NOT provide such a function, but PHP does.

Solution:

$string = strtr($string,
  array(
    'Search for this' => 'Replace with this',
    'Search something else' => 'Replace with something else'
    )
);