Witam,
Wyciagnolem sobie funkcje z wiki. ktora przerabia takie cuś np.:

{| border="1" cellpadding="2" cellspacing="0" align="right" width="300px" style="margin-left: 0.5em; margin-bottom: 0.5em" |+ Rumunia
România | align="center" colspan="2" style="background:#efefef;" | {| border="0" cellpadding="2" cellspacing="0" | align="center" width="160px" | Flaga Rumunii | align="center" width="140px" | Godło Rumunii |- | align="center" width="160px" | (o fladze) | align="center" width="140px" | (o godle) |} |---- | align="center" colspan="2" style="border-bottom:3px solid gray;" | Dewiza: brak |---- | align="center" colspan="2" | |---- | Język urzędowy | rumuński |---- | Stolica | Bukareszt |---- | Ustrój polityczny | demokracja parlamentarna |---- | Głowa państwa
| prezydent
Traian Băsescu |---- | Szef administracji
| premier
Calin Popescu-Tariceanu |---- | Powierzchnia
- całkowita
- wód śródląd. | 78.
238 391 km²
3,0% |---- | Liczba ludności
- ogółem (2003)
- gęstość zalud. | 49.
22 271 839
93,4/km² |---- | Uzyskanie niepodległości | od Imperium Osmańskiego
9 maja 1877 |---- | Waluta | Lej (ROL) |---- | Strefa czasowa | UTC +2 |---- | Hymn państwowy | ''Deşteaptă-te, Române!'' |---- | Domena internetowa | .ro |---- | Kod samochodowy | RO |---- | Numer kierunkowy | 40 |---- | align="center" colspan="2" style="border-bottom:3px solid gray;" | |}

na normalną tabelę..
funkcja wygląda tak:
  1. <?php
  2.  
  3. function doTableStuff ( $t ) { // tabela
  4. $fname = 'Parser::doTableStuff';
  5. wfProfileIn( $fname );
  6.  
  7. $t = explode ( &#092;"n\" , $t );
  8. $td = array (); # Is currently a td tag open?
  9. $ltd = array (); # Was it TD or TH?
  10. $tr = array (); # Is currently a tr tag open?
  11. $ltr = array (); # tr attributes
  12. $indent_level = 0; # indent level of the table
  13. foreach ( $t AS $k => $x )
  14. {
  15. $x = trim ( $x );
  16. $fc = substr ( $x , 0 , 1 );
  17. if ( preg_match( '/^(:*){|(.*)$/', $x, $matches ) ) {
  18. $indent_level = strlen( $matches[1] );
  19. $t[$k] = &#092;"n\" .
  20. str_repeat( '<dl><dd>', $indent_level ) .
  21. '<table ' . $this->fixTagAttributes ( $matches[2] ) . '>' ;
  22. array_push ( $td , false );
  23. array_push ( $ltd , '' );
  24. array_push ( $tr , false );
  25. array_push ( $ltr , '' );
  26. }
  27. else if ( count ( $td ) == 0 ) { } # Don't do any of the following
  28. else if ( '|}' == substr ( $x , 0 , 2 ) ) {
  29. $z = &#092;"</table>\" . substr ( $x , 2) . \"n\";
  30. $l = array_pop ( $ltd );
  31. if ( array_pop ( $tr ) ) $z = '</tr>' . $z ;
  32. if ( array_pop ( $td ) ) $z = '</'.$l.'>' . $z ;
  33. array_pop ( $ltr );
  34. $t[$k] = $z . str_repeat( '</dd></dl>', $indent_level );
  35. }
  36. else if ( '|-' == substr ( $x , 0 , 2 ) ) { # Allows for |---------------
  37. $x = substr ( $x , 1 );
  38. while ( $x != '' && substr ( $x , 0 , 1 ) == '-' ) $x = substr ( $x , 1 );
  39. $z = '' ;
  40. $l = array_pop ( $ltd );
  41. if ( array_pop ( $tr ) ) $z = '</tr>' . $z ;
  42. if ( array_pop ( $td ) ) $z = '</'.$l.'>' . $z ;
  43. array_pop ( $ltr );
  44. $t[$k] = $z ;
  45. array_push ( $tr , false );
  46. array_push ( $td , false );
  47. array_push ( $ltd , '' );
  48. array_push ( $ltr , $this->fixTagAttributes ( $x ) );
  49. }
  50. else if ( '|' == $fc || '!' == $fc || '|+' == substr ( $x , 0 , 2 ) ) { # Caption
  51. # $x is a table row
  52. if ( '|+' == substr ( $x , 0 , 2 ) ) {
  53. $fc = '+' ;
  54. $x = substr ( $x , 1 );
  55. }
  56. $after = substr ( $x , 1 );
  57. if ( $fc == '!' ) $after = str_replace ( '!!' , '||' , $after );
  58. $after = explode ( '||' , $after );
  59. $t[$k] = '' ;
  60.  
  61. # Loop through each table cell
  62. foreach ( $after AS $theline )
  63. {
  64. $z = '' ;
  65. if ( $fc != '+' )
  66. {
  67. $tra = array_pop ( $ltr );
  68. if ( !array_pop ( $tr ) ) $z = '<tr '.$tra.&#092;">n\" ;
  69. array_push ( $tr , true );
  70. array_push ( $ltr , '' );
  71. }
  72.  
  73. $l = array_pop ( $ltd );
  74. if ( array_pop ( $td ) ) $z = '</'.$l.'>' . $z ;
  75. if ( $fc == '|' ) $l = 'td' ;
  76. else if ( $fc == '!' ) $l = 'th' ;
  77. else if ( $fc == '+' ) $l = 'caption' ;
  78. else $l = '' ;
  79. array_push ( $ltd , $l );
  80.  
  81. # Cell parameters
  82. $y = explode ( '|' , $theline , 2 );
  83. # Note that a '|' inside an invalid link should not
  84. # be mistaken as delimiting cell parameters
  85. if ( strpos( $y[0], '[[' ) !== false ) {
  86. $y = array ($theline);
  87. }
  88. if ( count ( $y ) == 1 )
  89. $y = &#092;"{$z}<{$l}>{$y[0]}\" ;
  90. else $y = $y = &#092;"{$z}<{$l} \".$this->fixTagAttributes($y[0]).\">{$y[1]}\" ;
  91. $t[$k] .= $y ;
  92. array_push ( $td , true );
  93. }
  94. }
  95. }
  96.  
  97. # Closing open td, tr && table
  98. while ( count ( $td ) > 0 )
  99. {
  100. if ( array_pop ( $td ) ) $t[] = '</td>' ;
  101. if ( array_pop ( $tr ) ) $t[] = '</tr>' ;
  102. $t[] = '</table>' ;
  103. }
  104.  
  105. $t = implode ( &#092;"n\" , $t );
  106. # $t = $this->removeHTMLtags( $t );
  107. wfProfileOut( $fname );
  108. return $t ;
  109. }
  110.  
  111. ?>


i mam takie pytanie jak by wykorzystac ten kod questionmark.gif tzn zeby mi zrobił to co trzeba w zmiennej $content questionmark.gif z góry dzięki, chyba że jest ktoś tak zdolny i ambitny by napisać własne regexy questionmark.gif

z góry dzięki za pomoc