<?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';
echo "<ol>" , preg_replace_callback('~{([^}]*)}|(\S+)~', function($m) {
if (!isset($m[2])) {
return "<li><strong>{$m[1]}</strong></li>\n";
}
return "<li>{$m[2]}</li>\n";
},
$text) , "<ol>";