Ds \ Set::add()函数是PHP中的一个内置函数,用于向集合中添加值。
用法:
void public Ds\Set::add( $values )
参数:此函数接受单个参数$values,该参数包含要添加到集合中的许多值。
返回值:此函数不返回任何值。
以下示例程序旨在说明PHP中的Ds \ Set::add()函数:
程序1:
<?php
// Declare an empty set
$set = new \Ds\Set();
// Use add() function to
// add elements to the set
$set->add(1);
$set->add("Geeks");
$set->add("G");
$set->add(10);
var_dump($set);
?>
输出:
object(Ds\Set)#1 (4) {
[0]=>
int(1)
[1]=>
string(5) "Geeks"
[2]=>
string(1) "G"
[3]=>
int(10)
}
程序2:
<?php
// Declare an empty set
$set = new \Ds\Set();
// Use add() function to
// add elements to the set
$set->add(10, 20, 30, "Geeks", "for");
print_r($set);
?>
输出:
Ds\Set Object
(
[0] => 10
[1] => 20
[2] => 30
[3] => Geeks
[4] => for
)
参考: http://php.net/manual/en/ds-set.add.php
相关用法
- PHP exp()用法及代码示例
- p5.js log()用法及代码示例
- p5.js cos()用法及代码示例
- p5.js sin()用法及代码示例
- d3.js d3.mean()用法及代码示例
- p5.js second()用法及代码示例
- PHP Ds\Map map()用法及代码示例
- p5.js hue()用法及代码示例
- PHP ord()用法及代码示例
- p5.js pow()用法及代码示例
- p5.js day()用法及代码示例
- d3.js d3.sum()用法及代码示例
注:本文由纯净天空筛选整理自jit_t大神的英文原创作品 PHP | Ds\Set add() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
