3v4l.org

run code in 300+ PHP versions simultaneously
<?php $message = "We have received ##AMOUNT## ##CURRENCY## for your OrderID n. ##ORDER_ID##"; $messageParameters = [ 'AMOUNT' => 83, 'CURRENCY' => 'USD', 'ORDER_ID' => 3271096 ]; $parsedMessage = str_replace( array_map(function($v){ return '##'.$v.'##'; }, array_keys($messageParameters)), array_values($messageParameters), $message ); echo $parsedMessage;
Output for 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.29, 8.0.0 - 8.0.19, 8.1.0 - 8.1.6
We have received 83 USD for your OrderID n. 3271096

preferences:
48.71 ms | 409 KiB | 5 Q