I have objects such as these:
class Log
{
public matches;
public function __construct()
{
$this->matches = array();
}
}
class Match
{
public owner;
public stuff;
}
Throughout my program, I store data into $owner
and $stuff
and access it via iterating through the array matches for the Log object. What I am wondering is how to get an array containing a list of all the unique owners.
For example, if I have the following information:
Bill SomeStuff
Bob SomeOtherStuff
Stan MoreOtherStuff
Bill MoreOfBillsStuff
Bill BillhasLotsofStuff
How do I go about getting an array that contains merely Bill
, Bob
, Stan
?
This is an example function that you could add to the Log
class to return a list of owners:
function getOwners()
{
$owners = array();
foreach($this->matches as $match)
{
$owners[$match->owner] = 0;
}
return array_keys($owners);
}