NilovSerge 0 Newbie Poster

Help, please. I need edit programmatically(php) HTML-page so that,
for example all table's definitions change on my own definitions of tables
source:
<table ... many props... >
...
</table>
destination :
<table ... my props... >
...
</table>
And also I nees in result HTML leave some properties of the original table
(ex class="originalclass"). I need reg-funcs?

I tried:
$S= '<table valign=" bottom" border= 0 cellspacing=" 0" cellpadding=" 0" >
<td valign= top cellspacing=" 0"cellpadding=" 0" >
</table>

<table border= 0 width=" 100%" class=" SmallMenuTable ">
<tr>
<td width=" 17%" align= center>77777 </td>
</tr>
</table> ';
echo HtmlSpecialChars($S).'<br>'; // source string
echo preg_replace_callback ( "/<table (.+?)>/i", 'ChangeTableDef', $S ); // get all definitions of <table

function ChangeTableDef($matches) {
echo '<br><b>ChangeTableDef:::</b><br>';
echo $matches[0].'<br>'; // I get string : valign =" bottom" border= 0 cellspacing=" 0" cellpadding
echo $matches[1].'<br>';
echo $matches[2].'<br>'; // I need to get an array like array( array(valign=">bottom"), array(border=> 0)... )
$DefsArr= preg_match_all('/(.+?)[=](.+?)/', $matches[1], $Records); // wrong! How is wright?
unset($Records[0]);
foreach ($Records as $Rec) {
// if (condition)
$Res .= " ".$Rec[0]."=".$Rec[1];
}
return $Res;

}
...
and I doo not know, getting tags in this way I can change contest of tags <table ... >
and return the new value in ($params)ChangeTableDef($matches), but inside<table>...</table> there are
a lot of objects <tr> and <td>-cells I can lose them? How to tie all these object in one line?
How to do this? Maybe there are better ways to do this?
Please give the link to example of this!
With respect ,
Nilov Serge <nilov@vikoil.dn.ua>