I have a class that always has 14 instances. I'm just wondering if there is a better or more effective way of doing this. In this class I also have an array that is filled by calling 4 functions multiple times. Because this class is instanced 14 times, the array is duplicated a lot. What would be a better way to do this?
The following code is just placed at the bottom of the class file.
$machine1 = new machine('ZW01001', 41, "192.168.0.223");
$machine4 = new machine('ZW01004', 37, "192.168.0.216");
$machine5 = new machine('ZW01005', 28, "192.168.0.222 ");
$machine6 = new machine('ZW01006', 38, "192.168.0.217");
$machine7 = new machine('ZW01007', 30, "192.168.0.16");
$machine8 = new machine('ZW01008', 31, " 192.168.0.220");
$machine9 = new machine('ZW01009', 32, "192.168.0.218");
$machine10 = new machine('ZW01010', 40, "192.168.0.221");
$machine21 = new machine('ZW01021', 13, "192.168.0.215");
$machine22 = new machine('ZW01022', 2, "192.168.0.206");
$machine23 = new machine('ZW01023', 33, "192.168.0.213");
$machine24 = new machine('ZW01024', 34, "192.168.0.227");
$machine25 = new machine('ZW01025', 35, "192.168.0.226");
$machine26 = new machine('ZW01026', 36, "192.168.0.217");
$Cycle = (object) array(
'Machines' => array(
array(
'cycle' => $machine1->Cycle(),
'percent' => $machine1->GetM(),
'Data' => $machine1->Data(),
'ip' => $machine1->pingAddress(),
),
array(
'cycle' => $machine4->Cycle(),
'percent' => $machine4->GetM(),
'Data' => $machine4->Data(),
'ip' => $machine4->pingAddress(),
),
array(
'cycle' => $machine5->Cycle(),
'percent' => $machine5->GetM(),
'Data' => $machine5->Data(),
'ip' => $machine5->pingAddress(),
),
array(
'cycle' => $machine6->Cycle(),
'percent' => $machine6->GetM(),
'Data' => $machine6->Data(),
'ip' => $machine6->pingAddress(),
),
array(
'cycle' => $machine7->Cycle(),
'percent' => $machine7->GetM(),
'Data' => $machine7->Data(),
'ip' => $machine7->pingAddress(),
),
array(
'cycle' => $machine8->Cycle(),
'percent' => $machine8->GetM(),
'Data' => $machine8->Data(),
'ip' => $machine8->pingAddress(),
),
array(
'cycle' => $machine9->Cycle(),
'percent' => $machine9->GetM(),
'Data' => $machine9->Data(),
'ip' => $machine9->pingAddress(),
),
array(
'cycle' => $machine10->Cycle(),
'percent' => $machine10->GetM(),
'Data' => $machine10->Data(),
'ip' => $machine10->pingAddress(),
),
array(
'cycle' => $machine21->Cycle(),
'percent' => $machine21->GetM(),
'Data' => $machine21->Data(),
'ip' => $machine21->pingAddress(),
),
array(
'cycle' => $machine22->Cycle(),
'percent' => $machine22->GetM(),
'Data' => $machine22->Data(),
'ip' => $machine22->pingAddress(),
),
array(
'cycle' => $machine23->Cycle(),
'percent' => $machine23->GetM(),
'Data' => $machine23->Data(),
'ip' => $machine23->pingAddress(),
),
array(
'cycle' => $machine24->Cycle(),
'percent' => $machine24->GetM(),
'Data' => $machine24->Data(),
'ip' => $machine24->pingAddress(),
),
array(
'cycle' => $machine25->Cycle(),
'percent' => $machine25->GetM(),
'Data' => $machine25->Data(),
'ip' => $machine25->pingAddress(),
),
array(
'cycle' => $machine26->Cycle(),
'percent' => $machine26->GetM(),
'Data' => $machine26->Data(),
'ip' => $machine26->pingAddress(),
),
)
);
$fp = fopen('Rag.json', 'w');
fwrite($fp, json_encode($Cycle));
fclose($fp);