當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


PHP Ds\Collection::clear()用法及代碼示例


Ds\Collection::clear() 函數可以刪除所有值。

用法

abstract public void Ds\Collection::clear( void )

Ds\Collection::clear() 函數可以從集合中刪除所有值。

Ds\Collection::clear() 函數沒有任何參數。此函數不返回任何值。

示例1

<?php
   $collection = new \Ds\Vector([1, 2, 3, 4, 5, 6]); 
   print_r($collection);  

   $collection->clear(); 
   print_r($collection); 
?>

示例2

<?php 
   $collection = new \Ds\Vector([10, 15, 20, 25, 30, 35]);
   var_dump($collection);
  
   $collection->clear();
   var_dump($collection); 
?>

相關用法


注:本文由純淨天空篩選整理自 PHP - Ds\Collection::clear()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。