Hi guys.. I really hate RegEx, it's a mistery for me how to construct a regex pattern in order to make some changes in a string with preg_replace(). Sooo... here is my problem:
// clean if tag
//need to add somthing HERE
$item = preg_replace('/<(\/?)(table|tr|td).*?>/is', '<$1$2>', $item);
print_r($item);
$item carries a html string, actually a html table which will be filtered and parsed into an array. This is a part of an open source class which provides parsing a html table in to an array. But it cleans any code contained in <td> such as <td bgcolor=#FFCC99>. All I need is, before the tags are being cleaned, the bgcolor hex value to be moved inside the table cell.
Example:
If there is <td bgcolor=#FFCC99> in the string somewhere or <td bgcolor=#FFFFFF> no mather of the hex code, it will be replaced with <td>#FFCC99| or like the other example <td>#FFFFFF| so I can later parse the cell content to bgcolor and actual value with something like this explode("|", $string);
I hope my bad english was not fatal on this explanation