Re: how do you parse this?
| From: | Miguel Cruz | Date: | Tue, 30 Apr 2002 20:08:14 +0000 |
| Subject: | Re: how do you parse this? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-95432@lists.php.net to get a copy of this message | ||
On Tue, 30 Apr 2002, Lazor, Ed wrote:
> <ul><li><a href="¹
> GTh¢;Á°æhT:¹http:\\www.someaddress.com">SomeSite</a> This is a
> description of the site.</ul>
>
> I'm trying to parse out the address, site name, and description into
> separate variables. How can I do this?
I assume you mean http:// and not http:\\.
$str = '<ul><li><a href="http://www.someaddress.com">SomeSite</a>
This is a description of the site.</ul>';
preg_match('/href="(\S+)">(.+?)<\/a>(.+?)<\/ul>/', $str,
$matches);
print "Address: {$matches[1]}<br>Site:
{$matches[2]}<br>Description:{$matches[3]}";
It's all laid out on the preg pages in the manual.
miguel