PHP | Ds\Vector push()函数
Ds\Vector::push()函数是PHP中的一个内置函数,用于将元素添加到向量的末尾。
句法:
void public Ds\Vector::push( $values )
参数:此函数接受单个参数$values ,其中包含要添加到向量中的一个或多个元素。
返回值:此函数不返回任何值。
下面的程序说明了PHP中的Ds\Vector::push()函数:
方案一:
push(60);
echo("\nVector after appending the elements\n");
print_r($arr1);
?>
输出:
Original vector elements
Ds\Vector Object
(
[0] => 10
[1] => 20
[2] => 30
[3] => 40
[4] => 50
)
Vector after appending the elements
Ds\Vector Object
(
[0] => 10
[1] => 20
[2] => 30
[3] => 40
[4] => 50
[5] => 60
)
方案二:
push(...[60, 70]);
echo("\nVector after appending the elements\n");
print_r($arr1);
?>
输出:
Original vector elements
Ds\Vector Object
(
[0] => 10
[1] => 20
[2] => 30
[3] => 40
[4] => 50
)
Vector after appending the elements
Ds\Vector Object
(
[0] => 10
[1] => 20
[2] => 30
[3] => 40
[4] => 50
[5] => 60
[6] => 70
)
参考: http: PHP。 PHP