how do you replace this string *#ff00ff Hello World *000000 to <span style='color:#ff00ff'> Hello World </span> using str_replace?
Thanks.
$string = '*#ff00ff Hello World *000000';
$string = preg_replace('/\*#([a-f\d]{6})(.*)\*[a-f\d]+/', "<span style='color:$1'>$2</span>", $string);
echo $string;
can also be done like so:
$string = '*#ff00ff Hello World *000000';
$string = preg_replace('/\*#([[:xdigit:]]{6})(.*)\*[[:xdigit:]]+/', "<span style='color:$1'>$2</span>", $string);
echo $string;
$str = '*#ff00ff Hello World *000000';
preg_match('/(#[0-9a-f]{6})/i', $str, $matches);
echo "<span style='color:{$matches[1]}'> Hello World </span>";
$string = str_replace('*#ff00ff Hello World *000000', '<span style='color:#ff00ff'> Hello World </span', $string);Seriously, what are you trying to do? What have you tried and did not work?