Muhammad Yasir
Muhammad Yasir

Reputation: 426

Create one to many relationship between two classes in core PHP

Kindly can someone guide me on how to achieve this?

Upvotes: 1

Views: 299

Answers (1)

StepUp
StepUp

Reputation: 38144

You need to create Employee class:

class Employee 
{
    public $name
    public $phoneNumber
    public $mail
}

and Company class:

class Company 
{
    public $name;
    public $address;
    public $matchCount;
    public $employees = array();
}

You can use the following snippet:

$company = new Company();
$company->employees[0] = new Employee();

Upvotes: 1

Related Questions