Autor Zpráva
capricorn
Profil
Zdravim, mam nize uvedenou promennou, ze ktere potrebuji dostat veskere bunky do pole. Zkousel jsem to delat pres preg_match(), ale asi neco delam spatne, protoze to pole je vzdycky prazdne.

$table = '<div class=\"table1\">
          <table>
              <tr><td>(bla)</td><td style=\"width: 20px\">1.</td><th>tři</th></tr>
              <tr><td></td><td style=\"width: 20px\">2.</td><th>dva</th></tr>
          </table>
          </div>
          <div class=\"table2\">
          <table>
              <tr>(bla)<td style=\"width: 20px\">1.</td><th>jedna</th><td>(bla)</td></tr>
              <tr><td style=\"width: 20px\">2.</td><th>dva</th><td></td></tr>
          </table>
          </div>';
Joker
Profil
capricorn
Jak vypadá ten regulární výraz?
capricorn
Profil
Joker

preg_match("~<div class=\"table1\"><table><tr><td>(.+?)</td>~si", $table, $array);
preg_match("~<td style=\"width: 20px\">(.+?)</td>~si", $table, $array);
preg_match("~<th>(.+?)</th>~si", $table, $array);
preg_match("~<div class=\"table2\"><table><tr><td>(.+?)</td>~si", $table, $array);
preg_match("~<td style=\"width: 20px\">(.+?)</td>~si", $table, $array);
preg_match("~<th>(.+?)</th>~si", $table, $array);
Majkl578
Profil
preg_match_all('#<tr><td>(.*)<\/td><td style=\\\"width: 20px\\\">(.*)<\/td><th>(.*)<\/th><\/tr>#is', $string, $matches);
print_r($matches);
capricorn
Profil
Majkl578

Diky, ale ja bych potreboval, by vzniklo vicerozmerne pole, t.j.

Array
(
    [0] => Array
        (
            [td1] => Array
                (
                    [0] => (bla)
                    [1] => 
                )

            [td2] => Array
                (
                    [0] => 1.
                    [1] => 2.
                )

            [th] => Array
                (
                    [0] => tři
                    [1] => dva
                )

        )

    [1] => Array
        (
            [td2] => Array
                (
                    [0] => 1.
                    [1] => 2.
                )

            [th] => Array
                (
                    [0] => jedna
                    [1] => dva
                )

            [td3] => Array
                (
                    [0] => (bla)
                )

        )

)

Vaše odpověď

Mohlo by se hodit


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm:

0