[SOLVED] preg_match - <a href>
Posted: Wed Jan 19, 2005 5:08 pm
Hello,
If I kept searching I probably would eventually find my answer but I'm running out of time. I need to grab the link and the link text from an href.
IE:
I'm using the example from the manual (preg_match) to get the domain, OK great, but I'm having trouble getting the label. 'Elverta Joint Elementary School District'.
Here's my test code:
What do I need to add to get the text between the <a></a> tags?
Thanks!
- dstefani
If I kept searching I probably would eventually find my answer but I'm running out of time. I need to grab the link and the link text from an href.
IE:
Code: Select all
<a href="http://www.elverta.k12.ca.us/home/" target="content">Elverta Joint Elementary School District</a><br />Here's my test code:
Code: Select all
$handle = fopen("./yololinks.txt", "r");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
list($link) = $data;
preg_match("/^(<a href="http:\/\/)?(ї^\/]+)/i", $link, $matches);
$host = $matchesї2];
print "$host<p>\n";
}
fclose($handle);Thanks!
- dstefani