Con tutti quei test mi stava venendo il mal di testa
Io farei qualcosa del genere
codice:
<?php
$string = "Aliquam sed turpis metus, vel ultricies leo. Morbi nec elit neque.
<hr />
[OBJECT type='SPAN' F='Courier+New,0em,bold,none,252525,ffffff,none,none,none,252525,ffffff' L='null']tanto va la gatta al largo che ci lascia lo zampino[/OBJECT_SPAN]
<hr />
Ut ac scelerisque turpis. Etiam dapibus dolor sed justo placerat id mollis nisi placerat";
preg_match_all("#\[OBJECT\s+type='(.*?)'\s+F='(.*?)'\s+L='(.*?)'\](.*?)\[/OBJECT_SPAN\]#", $string, $match);
# print_r($match);
$css_properties = array('font-family: ',
'font-size: ',
'font-weight: ',
'font-style: ',
'color: #',
'background: #',
'text-align: ',
'text-decoration: ',
'text-transform: ');
$full_match = $match[0][0];
$tag = $match[1][0];
$style = urldecode($match[2][0]);
$title = urldecode($match[3][0]);
$text = $match[4][0];
$css_values = split(",", $style);
if ($title != 'null') {
$output = "<$tag title=\"$title\" style=\"";
} else {
$output = "<$tag style=\"";
}
for ($x = 0; $x < 8; $x++) {
if ($css_values[$x] != 'none') {
$output .= "{$css_properties[$x]}{$css_values[$x]}; ";
}
}
$output .= "\">$text</$tag>";
$string = str_replace($full_match, $output, $string);
echo $string;
?>
Ovviamente questo funziona solo col primo OBJECT trovato, va generalizzato per considerarli tutti usando la parte 'b' $match[a][b]