3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text = 'write {Hello, World!} in either the color {blue} or {red} or {#00AA00} and in either the font {Arial Black} or {Monaco} where both the color and the font are determined randomly'; var_export(preg_replace(['~{~', '~}~'], ['<strong>', '</strong'], preg_split('~({[^}]*}|\S+)\K ~', $text)));
Output for 5.6.38, 7.0.33, 7.1.25, 7.2.0 - 7.2.33, 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.25, 8.4.1 - 8.4.12
array ( 0 => 'write', 1 => '<strong>Hello, World!</strong', 2 => 'in', 3 => 'either', 4 => 'the', 5 => 'color', 6 => '<strong>blue</strong', 7 => 'or', 8 => '<strong>red</strong', 9 => 'or', 10 => '<strong>#00AA00</strong', 11 => 'and', 12 => 'in', 13 => 'either', 14 => 'the', 15 => 'font', 16 => '<strong>Arial Black</strong', 17 => 'or', 18 => '<strong>Monaco</strong', 19 => 'where', 20 => 'both', 21 => 'the', 22 => 'color', 23 => 'and', 24 => 'the', 25 => 'font', 26 => 'are', 27 => 'determined', 28 => 'randomly', )

preferences:
100.1 ms | 409 KiB | 5 Q