Gigi Posted June 1, 2006 Report Share Posted June 1, 2006 (edited) Sveiki, vai kāds nezin vienkāšu un ātrū iespēju, ka no html teksta dabūt arā vajadzīgos datus! piemērs: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>blank</title> </head> ...html kods <p>Tel: 28848389</p> <p>Adrese: Riga</p> Nr: 10-00002 ... vel html kods Nr: 90-00003 <p>Adrese: Liepaja</p> Tel: 23565995 ... vel html kods </html> Rezultāts: (tīri vajadzīgie dati, bez html) Tel: 28848389 Adrese: Riga Nr: 10-00002 Tel: 23565995 Adrese: Liepaja Nr: 90-00003 tas tā, lai saprotamāk, bet labāk būtu bez (Tel:, Adrese:, Nr:) priekšā! Edited June 1, 2006 by Gigi Link to comment Share on other sites More sharing options...
litt Posted June 1, 2006 Report Share Posted June 1, 2006 Ielasi failu kā stringu un tad stringam izpildi strip_tags Link to comment Share on other sites More sharing options...
Delfins Posted June 1, 2006 Report Share Posted June 1, 2006 preg Link to comment Share on other sites More sharing options...
Gigi Posted June 1, 2006 Author Report Share Posted June 1, 2006 (edited) litt variants man nederēs, tas tikai atitīris no tagiem. preg derēs, cik saprotu vajag 'sākuma tāgu' un 'beigu tāgu', varbut delfins varētu lūdzu pateikt, kā izkatītos vienkārša regulāra izteiksme, ja Tel: - sakuma tāgs, bet beigu tāgs pirmajā variantā - </p>, otrajā - tukšuma simbols, lai ka stringu atgriež telefona numuru? Edited June 1, 2006 by Gigi Link to comment Share on other sites More sharing options...
elfz Posted June 1, 2006 Report Share Posted June 1, 2006 kā izkatītos vienkārša regulāra izteiksme, ja Tel: - sakuma tāgs, bet beigu tāgs pirmajā variantā - </p> preg_match_all('/Tel: (.+)<\/p>/U', $html, $matches); foreach($matches[1] as $match) echo "$match "; Link to comment Share on other sites More sharing options...
Gigi Posted June 1, 2006 Author Report Share Posted June 1, 2006 (edited) paldies elfz! Šadā variantā, man pat beigu tāgu nevajag zināt: preg_match_all('/Tel: (.+)/', $html, $matches); foreach($matches[1] as $match) echo "$match"; un ja nu tomēr kāds html tāgs palicis: strip_tags($match). Edited June 1, 2006 by Gigi Link to comment Share on other sites More sharing options...
Recommended Posts