Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Stillfinder's avatar

str_replace || ! str_replace ?

Hi, is it ok to use this? Or maybe there is a better solution?

$parameters['body'] = str_replace('<pre>', '<pre><code>', $parameters['body']);
$parameters['body'] = str_replace('</pre>', '</pre></code>', $parameters['body']);
0 likes
2 replies
Ashraam's avatar

it's ok, you could inline it like this

$parameters['body'] = str_replace(['<pre>', '</pre>'], ['<pre><code>', '</code></pre>'], $parameters['body']);
1 like

Please or to participate in this conversation.