For example:
$product = new Product(\"cat\"); if(isset($sales[$product])){ $sales[$product]++; } else{ $sales[$product] = 1; }
There is a spl_object_hash function for getting unique object id as string, which can be used as array key. http://php.net/manual/en/function.spl-object-hash.php