3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = 'This thing should output _$this_key$_ and also _$this_one$_ so that I can match it with an array!'; $replacements = [ 'this_key' => 'love', 'this_one' => 'more love' ]; $start = '_$'; $end = '$_'; $replacements = array_combine(array_map(function ($v) use ($start, $end) { return "$start$v$end"; }, array_keys($replacements)), $replacements); echo strtr($str, $replacements);
Output for 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.27, 8.4.1 - 8.4.14
This thing should output love and also more love so that I can match it with an array!

preferences:
162.3 ms | 407 KiB | 5 Q