日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

count函数里加函数_PHP count()函数与示例

發布時間:2025/3/11 php 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 count函数里加函数_PHP count()函数与示例 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

count函數里加函數

PHP count()函數 (PHP count() function)

"count() function" is used to get the total number of elements of an array.

“ count()函數”用于獲取數組元素的總數。

Syntax:

句法:

count(array, [count_mode])

Here,

這里,

  • array is the name of an input array

    array是輸入數組的名稱

  • count_mode is an optional parameter and it's default value is 0, it has two values

    count_mode是一個可選參數,默認值為0,它有兩個值

    0 – It does not count all elements of a multidimensional array

    0 –不計算多維數組的所有元素

    1 – It counts all elements of a multidimensional array

    1 –計算多維數組的所有元素

Examples:

例子:

Input:$arr1 = array("101", "102", "103", "104", "105");Output:arr1 has 5 elements

PHP code: Using single dimensional array

PHP代碼:使用一維數組

<?php $arr1 = array("101", "102", "103", "104", "105");$arr2 = array("Amit", "Abhishek", "Prerana", "Aleesha", "Prem");$len = count($arr1);print ("arr1 has $len elements\n");$len = count($arr2);print ("arr2 has $len elements\n"); ?>

Output

輸出量

arr1 has 5 elements arr2 has 5 elements

PHP code: Using multidimensional array

PHP代碼:使用多維數組

<?php $students = array("101" => array("name" => "Amit","age" => 21,),"102" => array("name" => "Abhi","age" => 20,));$len = count($students);print ("count value = $len (count_mode is not provided)\n");$len = count($students, 0);print ("count value = $len (count_mode is set to 0)\n"); $len = count($students, 1);print ("count value = $len (count_mode is set to 1)\n"); ?>

Output

輸出量

count value = 2 (count_mode is not provided) count value = 2 (count_mode is set to 0) count value = 6 (count_mode is set to 1)

翻譯自: https://www.includehelp.com/php/count-function-with-example.aspx

count函數里加函數

總結

以上是生活随笔為你收集整理的count函数里加函数_PHP count()函数与示例的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。