Here's an example of what the .html file looks like:
**********************************************************
Code: Select all
<tr valign="top">
<td>African Student Drama Association </td>
<td>Through the common interest of art, foster unity among students and scholars at SDSU. </td>
<td>Adeyinka Glover </td>
<td>afdeyinkaglover2005@yahoo.com</td>
</tr>
<tr valign="top">
<td><span style="font-family:times new roman;font-size:16px;">Air Force ROTC, Detachment 075 Honor Guard "The Nighthawks"</span> </td>I am trying to ideally echo only the "afdeyinkaglover2005@yahoo.com back onto the screen.
Here is the code I've created:
***********************************************************
Code: Select all
<?php
$file = "./test2.txt";
$handle = @fopen($file, "r");
$reg = '/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/';
if ($handle)
{
while (!feof($handle)) {
$buffer = fgetss($handle,4096);
}
if(preg_match_all($reg, $buffer, $matches)) {
foreach( $matches as $val => $i) {
echo $val[$i];
}
} else {
echo "no emails in file";
}
fclose($handle);
}
?>This code returns "no emails in file". I am new to PHP, but am a coder.. just feel a little lost. Can anyone please help?
Thank you