I'm struggling to find the problem with the following piece of PHP code:
The code is as follows
class WorkerThreads extends Thread
{
private $from_list;
public function __construct($x,$host,$users_email,$pass,$inbox)
{
$this->from_list = array(); # holds the unique froms extracted from headers
}
public function run()
{
# Get Froms
if (preg_match('/From\:\ (.+)/i', $headers, $matches, PREG_OFFSET_CAPTURE)) {
$from = trim(str_ireplace("From: ", "", $matches[0][0]));
if (!array_key_exists($from, $this->from_list)) {
$this->from_list[$from] = 1;
echo "<br/>FROM: ".$from."-".$this->from_list[$from]."<br/><br/>";
}
} else {
echo "NO FROM <br/><rb/>";
}
The following error occurs:
Notice: Undefined index: Viva in /var/www/BAMCode/yahoofroms.php on line 198
FROM: Viva-
The offending line 200 is
echo "<br/>FROM: ".$from."-".$this->from_list[$from]."<br/><br/>";
There seems to be a problem with the array
FROM: ".$from."-".$this->from_list[$from]."
"; The $from contains Viva - the array for some reason is generating the error... – Del Jun 10 '15 at 02:13