PHP Ds/Set count() 函數

| | | | | | | | |
語法:
int public DsSet::count()
參數:這個函數沒有參數。返回value:此函數返回 Set 實例中存在的值的數量。以下程序說明了 Ds 函數 / Set::count() 程序 1: <代碼><代碼>
// 聲明一個新集合$set = new DsSet ([10, 15, 21]);
// 顯示集合元素var_dump ( $set );
//顯示項數
// 存在於集合中echo "Count is:" ; print_r ( $set -> count ());
?> 退出:
object (DsSet ) # 1 (3) {[0] = > int (10) [1] = > int (15) [2] => int (21)} 計數為:3
程序2:
// 聲明一個新集合$set = new DsSet ( [ "Geeks" , "for" , "Keegs" ]);
// 顯示設置元素var_dump ( $set );
//顯示項數
//存在於集合中echo "計數為:" ; print_r ( $set -> count ());
?>
Exit:
object (DsSet) #1 (3) {[0] => string (5) "Geeks" [1] = > string (3) "for " [2] = > 字符串 (5) "Keegs"} 計數為:3
鏈接: http://php.net/manual/en/ds-set。計數.php