📜  PHP | SplFixedArray offsetUnset ()函数

📅  最后修改于: 2022-05-13 01:56:23.891000             🧑  作者: Mango

PHP | SplFixedArray offsetUnset ()函数

SplFixedArray::offsetUnset()函数是PHP中的一个内置函数,用于取消设置请求索引的值。

句法:

void SplFixedArray::offsetUnset( $index )

参数:此函数接受单个参数$index ,该参数指定需要取消设置其值的所需索引。

返回值:此函数不返回任何值。

下面的程序说明了PHP中的SplFixedArray::offsetUnset()函数:

方案一:

offsetGet(2));
  
// Unset offset
$gfg->offsetUnset (2);
  
// Print after unset
var_dump($gfg->offsetGet(2));
  
?>
输出:
int(10)
NULL

方案二:

offsetGet($i));
  
    // Unset offset
    $gfg->offsetUnset ($i);
  
    // Print after unset
    var_dump($gfg->offsetGet($i));
  
    $i++;
}
?>
输出:
int(1)
NULL
int(5)
NULL
int(1)
NULL
int(11)
NULL
int(15)
NULL
int(17)
NULL

参考: https://www. PHP.net/manual/en/splfixedarray.offsetunset。 PHP