From: "Zoran" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, September 03, 2004 12:35 PM Subject: [PHP] Web Fetch & Process
Hi How can I parse HTML page which I fetched by PHP so some part of text would be replaced by other text. For example, if I have bold text on HTML page (<b>Some text</b>) how can I manage that all bold text on that page is replaced by some other text. Also, I managed to delete all HTML code from page (with this code $data[0] = preg_replace("/([<])+([^>])+([.])*([>])+/i","", $data[0]); but also would like to delete all chars except numbers from page, can this be done? Regards. Zoran Your first question: To replace certain elements take a look at preg_replace() http://us4.php.net/manual/en/function.preg-replace.php Example: $foo = 'stuff <b>silly stuff</b> more stuff'; echo preg_replace('/\<b\>(.*)\<\/b\>/', "<h1>$1 lookie now</h1>", $foo); Your second question: You could just use strip_tags() http://us4.php.net/manual/en/function.strip-tags.php Your last question: To delete everything but numbers you could $content = preg_replace('/[^\d]/','', $content); Hope that helps Jim Grill -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php