I currently have 2 classes:
workerListClass
workerClass
The workerListClass gets a list of work with ids from database. For each of these the workerClass is called
foreach ($query as $value) {
$result = $this->worker->getWorkerById($value['ID']); // DB Call to get additional data
$this->addData($result);
vardumper::dump($result->getId());
// This results in 1031 and 1528
}
addDate is very simple
public function addData(workerClass $worker): void
{
$this->data[] = $worker;
}
But if i try to go through this array something strange happens
$result = $this->workerListClass->getWorker()->getData();
foreach ($result as $worker) {
vardumper::dump([
$worker->getId() // this outputs 1528 twice!!!
]);
}
getData does nothing special
public function getData(): array
{
return $this->data;
}
Can someone help me why this outputs 1528 twice?
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)