Ds\Vector::set() 函数可以更新给定索引处的值。
用法
public void Ds\Vector::set( int $index, mixed $value )
Ds\Vector::set() 函数不返回任何值。如果索引无效,此函数可能会抛出 OutOfRangeException。
例子1
<?php
$vector = new \Ds\Vector([1, 2, 3, 4, 5]);
print_r($vector);
$vector->set(1, 10);
echo("\n The vector after updating an element:\n");
print_r($vector);
?>
例子2
<?php
$vector = new \Ds\Vector(["Tutorials", "Point", "Tutorix"]);
print_r($vector);
$vector->set(1, "India");
echo("\n The vector after updating an element:\n");
print_r($vector);
?>
相关用法
- PHP Ds Vector sum()用法及代码示例
- PHP Ds Vector sorted()用法及代码示例
- PHP Ds Vector slice()用法及代码示例
- PHP Ds Vector sort()用法及代码示例
- PHP Ds Vector allocate()用法及代码示例
- PHP Ds Vector get()用法及代码示例
- PHP Ds Vector count()用法及代码示例
- PHP Ds Vector unshift()用法及代码示例
- PHP Ds Vector rotate()用法及代码示例
- PHP Ds Vector last()用法及代码示例
- PHP Ds Vector push()用法及代码示例
- PHP Ds Vector first()用法及代码示例
- PHP Ds Vector jsonSerialize()用法及代码示例
- PHP Ds Vector insert()用法及代码示例
- PHP Ds Vector construct()用法及代码示例
- PHP Ds Vector contains()用法及代码示例
- PHP Ds Vector toArray()用法及代码示例
- PHP Ds Vector merge()用法及代码示例
- PHP Ds Vector join()用法及代码示例
注:本文由纯净天空筛选整理自 PHP - Ds Vector set() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。