本文整理汇总了PHP中Set::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Set::toArray方法的具体用法?PHP Set::toArray怎么用?PHP Set::toArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Set
的用法示例。
在下文中一共展示了Set::toArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRemove
public function testRemove()
{
$set1 = new Set();
$set2 = new Set([100, 200]);
$set1->add(200);
$set1->add(300);
$set2->retainAll($set1);
$this->assertEquals($set1->toArray(), [200, 300]);
$this->assertEquals($set2->toArray(), [200]);
$this->assertFalse($set1->equals($set2));
$this->assertFalse($set2->equals($set1));
$set1->remove(300);
$this->assertTrue($set1->equals($set2));
$this->assertTrue($set2->equals($set1));
$set1->removeAll($set2);
$this->assertTrue($set1->isEmpty());
$this->assertFalse($set2->isEmpty());
}
示例2: difference
/**
* Creates the difference of A and B.
*
* @param Set $a
* @param Set $b
*
* @return Set
*/
public static function difference(Set $a, Set $b) : Set
{
return new self(array_diff($a->toArray(), $b->toArray()));
}