$s=implode('',array("$buf")); $s=strstr($s,"<GOS_ANS>"); preg_match_all("/<([a-zA-Z0-9:\"= ]+)>([^<]*)<\/[a-zA-Z0-9:]+>/",$s,$match); $col=count(array_unique($match[1])); echo "<table border=0>"; echo "<tr>"; for($q=0;$q<$col;$q++){ echo "<td>".$match[1][$q]."</td>"; } echo "</tr>"; for($w=0;$w<count($match[1]);$w++){ echo "<tr bgcolor='#C9C9C9'>"; $w = $w+2; for($q=0;$q<$col;$q++){ echo "<td>".$match[2][$q+$w*$col]."</td>"; } echo "<tr>"; $w = $w-1; for($q=0;$q<$col;$q++){ echo "<td>".$match[2][$q+$w*$col]."</td>"; } echo "</tr>"; } echo "</table>";