Re: Web Fetch & Process

From: Date: Fri, 03 Sep 2004 20:05:15 +0000
Subject: Re: Web Fetch & Process
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-195774@lists.php.net to get a copy of this message
From: "Zoran" <liste@komadi.com> To: <php-general@lists.php.net> 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

« previous php.general (#195774) next »