I am attempting to stitch together an array of objects from combining 2-3 arrays, shown here:
while($j < $itemCounter && $i < $histCounter)
{
if($hists[$i]->itemid == $items[$j]->itemid)
{
//echo $i."\n";
$doc[$i]->clock = intval($hists[$i]->clock); <-line 218
$doc[$i]->value = floatval($hists[$i]->value);
$doc[$i]->name = $items[$j]->name;
$doc[$i]->hostname = $hostName[intval($items[$j]->hostid)];
$i++;
}
else
{
//echo intval($hists[$i]->itemid) ."\t". intval($items[$j]->itemid)."\n";
//echo $j."\n";
if($hists[$i]->itemid > $items[$j]->itemid) $j++;
else $i++;
}
}
And I keep getting a whole lot of these
PHP Warning: Creating default object from empty value in **.php on line 218
I also get a lot of notice lines but .. I think fixing this issue may solve my problem.
Am I doing object building completely wrong? Do I need to build a class and object and structure this totally different?
This is my declaration for $doc at the moment:
$doc = NULL;