Autor | Zpráva | ||
---|---|---|---|
capricorn Profil |
#1 · Zasláno: 13. 1. 2009, 13:46:09 · Upravil/a: capricorn
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 |
#2 · Zasláno: 13. 1. 2009, 13:49:00
capricorn
Jak vypadá ten regulární výraz? |
||
capricorn Profil |
#3 · Zasláno: 13. 1. 2009, 13:56:17
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 |
#4 · Zasláno: 13. 1. 2009, 14:12:48 · Upravil/a: Majkl578
preg_match_all('#<tr><td>(.*)<\/td><td style=\\\"width: 20px\\\">(.*)<\/td><th>(.*)<\/th><\/tr>#is', $string, $matches); print_r($matches); |
||
capricorn Profil |
#5 · Zasláno: 13. 1. 2009, 14:44:54
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) ) ) ) |
||
Časová prodleva: 15 let
|
0