PHP | Ds\Deque 合并()函数
Ds\Deque::merge()函数是PHP中的一个内置函数,用于在将一个 Deque 的所有元素与另一个合并后返回合并的 Deque,方法是将所有值添加到副本中并返回该副本。
句法:
public Ds\Deque::merge( $values ) : Ds\Deque
参数:此函数接受单个参数$values ,其中包含要与调用 Deque 合并的值。
返回值:此函数返回一个包含两个 Deque 的所有元素的 Deque。
下面的程序说明了PHP中的Ds\Deque::merge()函数:
方案一:
merge($deck2));
?>
输出:
Elements of first deque
Ds\Deque Object
(
[0] => 10
[1] => 20
[2] => 30
[3] => 40
[4] => 50
[5] => 60
)
Elements of second deque
Ds\Deque Object
(
[0] => 70
[1] => 80
[2] => 90
[3] => 100
)
Merged deque elements
Ds\Deque Object
(
[0] => 10
[1] => 20
[2] => 30
[3] => 40
[4] => 50
[5] => 60
[6] => 70
[7] => 80
[8] => 90
[9] => 100
)
方案二:
merge($deck2));
?>
输出:
Elements of first deque
Ds\Deque Object
(
[0] => geeks
[1] => for
[2] => geeks
)
Elements of second deque
Ds\Deque Object
(
[0] => practicing
[1] => data
[2] => structures
)
Merged deque elements
Ds\Deque Object
(
[0] => geeks
[1] => for
[2] => geeks
[3] => practicing
[4] => data
[5] => structures
)
参考: http: PHP。 PHP