3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = "We have received ##AMOUNT## ##CURRENCY## for your OrderID n. ##ORDER_ID##"; $AMOUNT = 123; $CURRENCY = 'GBP'; $ORDER_ID = 20123; $find = ['AMOUNT', 'CURRENCY', 'ORDER_ID']; echo str_replace( array_map(function($v){ return '##'.$v.'##'; }, $find), compact(...$find), $str );

preferences:
9.63 ms | 409 KiB | 5 Q