3v4l.org

run code in 300+ PHP versions simultaneously
<?php $optimization_prompt = '[not a key] The product title is [title] and the price is [price] and this product link is [link]'; $get_product = ['title' => 'theTitle', 'price' => 45, 'link' => 'https://thelink.com']; $result = str_replace( array_map(fn($k) => "[$k]", array_keys($get_product)), $get_product, $optimization_prompt ); echo $result;
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
[not a key] The product title is theTitle and the price is 45 and this product link is https://thelink.com

preferences:
76.39 ms | 407 KiB | 5 Q