|
Posted by Vince Morgan on 04/25/07 13:42
"ana" <anka@vizualmedia.hr> wrote in message
news:f0n5jp$er$1@ss408.t-com.hr...
> I'm not very good programer, I use one php script for cms for flash.
> When I make changes in text in this CMS, for example I put letters bold,
> this script puts <strong></strong> on beginning and the end, but I need
> <b></b> so I use str_replace to replace strong with b, and this is ok.
>
> But when I change a color, this script puts for example <font
color=#CCCCCC>
> in front of letters but I need <font color="#CCCCCC"> because Flash won't
> read it without quotes. And I can't say str_replace #CCCCCC with "#CCCCCC"
> because I don't know wich color the person will choose.
>
> Please if you have some idea help me!
>
>
This is probably a very convoluted solution but it's late and I've not had
to do this previously in php.
You will need to loop to the end of the string, which I haven't done. I
haven't tested it either, but it should work with some modification.
$f='This is a search for <font-color=#CCCCCC> and that';
$pos=array(0, 1);
$pos[0]=stripos($f, 'font-color=#', $pos[0]);
$pos[1]=stripos($f, '=', $pos[0]);
$f=substr_replace($f, '="',$pos[1], 1);
$pos[0]=stripos($f, '>', $pos[1]);
$f=substr_replace($f, '">', $pos[0], 1);
echo $f;
HTH
Vince
[Back to original message]
|