Jump to content

[SOLVED] Repeated Result


ballouta

Recommended Posts

Hello

i have this ereg that reads a returned email with non exisitng email addresses, it works good but it repeats each email address twice or three times according to how many times it is mentioned in the returened email:

 

<?php
preg_match_all('#([^\s<]+@[^\s>]+)#', $message, $matches);
for($i = 0, $total = count($matches[0]); $i < $total; $i++){
   echo $matches[0][$i] . '<br />';
}
?>

 

example of a delviery failure message (twice repeated):

Message from yahoo.co.uk.

Unable to deliver message to the following address(es).

 

<[email protected]>:

This user doesn't have a yahoo.co.uk account ([email protected]) [0]

 

Would you please help me solve this problem?

 

thank You

 

Link to comment
https://forums.phpfreaks.com/topic/123657-solved-repeated-result/
Share on other sites

<pre>
<?php
$message = <<<MSG
Message from yahoo.co.uk.
Unable to deliver message to the following address(es).

<[email protected]>:
This user doesn't have a yahoo.co.uk account ([email protected]) 
MSG;
preg_match_all('#[^\s<()]+@[^\s>()]+#', $message, $matches);
foreach (array_unique($matches[0]) as $match) {
	echo $match, '<br />';
}
?>
</pre>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.