Cách tốt nhất là chuyển đổi thời gian trong vài giây và sau đó thêm chúng và một lần nữa chuyển đổi chúng thành định dạng có thể đọc được. Giống như dưới đây:
function sum_the_time[$times] {
$seconds = 0;
foreach [$times as $time] {
list[$hour, $minute, $second] = explode[':', $time['time_in_minutes']];
$seconds += $hour*3600;
$seconds += $minute*60;
$seconds += $second;
}
$hours = floor[$seconds/3600];
$seconds -= $hours*3600;
$minutes = floor[$seconds/60];
$seconds -= $minutes*60;
if [$seconds < 9] {
$seconds = "0" . $seconds;
}
if [$minutes < 9] {
$minutes = "0" . $minutes;
}
if[$hours < 9] {
$hours = "0" . $hours;
}
return "{$hours}:{$minutes}:{$seconds}";
}
Trong ví dụ trên, $time
là một mảng.
8 năm trước
MuaTV tại Gmail Dot Com ¶ — Counts all elements in an array or in a Countable object
Jumpifbelow ¶
Jerome Dot GDS tại Gmail Dot Com ¶[Countable|array $value
, int $mode
= COUNT_NORMAL
]: int
3 năm trước
Vojtaripa tại Gmail Dot Com ¶2 năm trướcCountable object.
Điều này không quan trọng ¶6 năm trướcint[3]
Warning: count[]: Parameter must be an array or an object that implements Countable in … on line 12
int[0]
Warning: count[]: Parameter must be an array or an object that implements Countable in … on line 14
int[1]
0 [or 1], count[] will recursively count the array. This is particularly useful for counting all the elements of a multidimensional array.
Asma Mechtaba ¶
7 tháng trước can detect recursion to avoid an infinite loop, but will emit an int[3]
Warning: count[]: Parameter must be an array or an object that implements Countable in … on line 12
int[0]
Warning: count[]: Parameter must be an array or an object that implements Countable in … on line 14
int[1]
1 every time it does [in case the array contains itself more than once] and return a count
higher than may be expected.
Flavioaugusto dot br tại gmail dot com ¶
Tối đa tại Schimmelmann Dot org ¶array nor an object that implements the Countable interface,
int[3] Warning: count[]: Parameter must be an array or an object that implements Countable in … on line 12 int[0] Warning: count[]: Parameter must be an array or an object that implements Countable in … on line 14 int[1]3 would be returned, unless
value
was int[3] Warning: count[]: Parameter must be an array or an object that implements Countable in … on line 12 int[0] Warning: count[]: Parameter must be an array or an object that implements Countable in … on line 14 int[1]5, in which case
int[3] Warning: count[]: Parameter must be an array or an object that implements Countable in … on line 12 int[0] Warning: count[]: Parameter must be an array or an object that implements Countable in … on line 14 int[1]6 would be returned.
Xavdeb ¶
8.0.0 | Jerome Dot GDS tại Gmail Dot Com ¶ will now throw TypeError on invalid countable types passed to the value parameter.
|
7.2.0 | 3 năm trước will now yield a warning on invalid countable types passed to the value parameter.
|
Vojtaripa tại Gmail Dot Com ¶
2 năm trướccount[] example
int[3] Warning: count[]: Parameter must be an array or an object that implements Countable in … on line 12 int[0] Warning: count[]: Parameter must be an array or an object that implements Countable in … on line 14 int[1]9
Điều này không quan trọng ¶
6 năm trướccount[] non Countable|array example [bad example - don't do this]
int[3] Fatal error: Uncaught TypeError: count[]: Argument #1 [$var] must be of type Countable .. on line 120
Điều này không quan trọng ¶
6 năm trước
int[3] Warning: count[]: Parameter must be an array or an object that implements Countable in … on line 12 int[0] Warning: count[]: Parameter must be an array or an object that implements Countable in … on line 14 int[1]
Asma Mechtaba ¶
int[3] Fatal error: Uncaught TypeError: count[]: Argument #1 [$var] must be of type Countable .. on line 12
7 tháng trướccount[] example
int[3] Fatal error: Uncaught TypeError: count[]: Argument #1 [$var] must be of type Countable .. on line 121
Điều này không quan trọng ¶
6 năm trướcCountable object
int[3] Fatal error: Uncaught TypeError: count[]: Argument #1 [$var] must be of type Countable .. on line 122
int[3] Fatal error: Uncaught TypeError: count[]: Argument #1 [$var] must be of type Countable .. on line 123
int[3] Fatal error: Uncaught TypeError: count[]: Argument #1 [$var] must be of type Countable .. on line 124
Điều này không quan trọng ¶
6 năm trước
- Asma Mechtaba ¶
- 7 tháng trước
- Flavioaugusto dot br tại gmail dot com ¶
- Tối đa tại Schimmelmann Dot org ¶
- Xavdeb ¶
- [Php 4, Php 5, Php 7, Php 8]
Đếm - Đếm tất cả các phần tử trong một mảng hoặc trong một đối tượng có thể đếm được ¶
Gerd Christian Kunze ¶
int[3] Fatal error: Uncaught TypeError: count[]: Argument #1 [$var] must be of type Countable .. on line 125
int[3] Fatal error: Uncaught TypeError: count[]: Argument #1 [$var] must be of type Countable .. on line 126
int[3] Fatal error: Uncaught TypeError: count[]: Argument #1 [$var] must be of type Countable .. on line 127
int[3] Fatal error: Uncaught TypeError: count[]: Argument #1 [$var] must be of type Countable .. on line 128
int[3] Fatal error: Uncaught TypeError: count[]: Argument #1 [$var] must be of type Countable .. on line 129
$time
0
$time
1
$time
2
8 năm trước ¶
PHP_Count tại cubmd dot com ¶
$time
3
$time
4
$time
5
$time
6
$time
7
$time
8
$time
25 năm trước ¶
PHP_Count tại cubmd dot com ¶
$value
0
$value
1
$time
2Danny tại Dannymendel Dot Com ¶ ¶
15 năm trước
$value
3
$value
4
$time
2Alexandr tại Vladykin dot pp dot ru ¶ ¶
15 năm trước
$value
6
$value
7
$value
8
$value
9Alexandr tại Vladykin dot pp dot ru ¶ ¶
Christoph097 ¶
$mode
0
10 tháng trước ¶
Pied-Pierre ¶
$mode
1
$mode
2
$time
27 năm trước ¶
PHP_Count tại cubmd dot com ¶
$mode
4
$mode
5
$mode
6
$mode
75 năm trước ¶
Gerd Christian Kunze ¶
$mode
8
$mode
9
COUNT_NORMAL
0
$time
28 năm trước ¶
PHP_Count tại cubmd dot com ¶
COUNT_NORMAL
2
COUNT_NORMAL
3
COUNT_NORMAL
4
$time
25 năm trước ¶
Pied-Pierre ¶
COUNT_NORMAL
6
COUNT_NORMAL
7
$time
27 năm trước ¶
PHP_Count tại cubmd dot com ¶
COUNT_NORMAL
9
value
0
value
1
value
2
value
3
value
4
value
5
value
68 năm trước ¶
PHP_Count tại cubmd dot com ¶
value
7
value
8
value
9
$time
25 năm trước ¶
Gerd Christian Kunze ¶
mode
1
mode
2
$time
28 năm trước ¶
MuaTV tại Gmail Dot Com ¶
mode
4
mode
5
mode
6
mode
7Jumpifbelow ¶ ¶
Jerome Dot GDS tại Gmail Dot Com ¶
mode
8
3 năm trước ¶
PHP_Count tại cubmd dot com ¶
mode
9
mode
0
mode
1
mode
2
mode
3
mode
4
mode
5
mode
6
mode
7
$time
25 năm trước ¶
Gerd Christian Kunze ¶
mode
9
int[3] Warning: count[]: Parameter must be an array or an object that implements Countable in … on line 12 int[0] Warning: count[]: Parameter must be an array or an object that implements Countable in … on line 14 int[1]00
int[3] Warning: count[]: Parameter must be an array or an object that implements Countable in … on line 12 int[0] Warning: count[]: Parameter must be an array or an object that implements Countable in … on line 14 int[1]01
int[3] Warning: count[]: Parameter must be an array or an object that implements Countable in … on line 12 int[0] Warning: count[]: Parameter must be an array or an object that implements Countable in … on line 14 int[1]02
Xavdeb ¶ ¶
2 năm trước
int[3] Warning: count[]: Parameter must be an array or an object that implements Countable in … on line 12 int[0] Warning: count[]: Parameter must be an array or an object that implements Countable in … on line 14 int[1]03
int[3] Warning: count[]: Parameter must be an array or an object that implements Countable in … on line 12 int[0] Warning: count[]: Parameter must be an array or an object that implements Countable in … on line 14 int[1]04
int[3] Warning: count[]: Parameter must be an array or an object that implements Countable in … on line 12 int[0] Warning: count[]: Parameter must be an array or an object that implements Countable in … on line 14 int[1]05
int[3] Warning: count[]: Parameter must be an array or an object that implements Countable in … on line 12 int[0] Warning: count[]: Parameter must be an array or an object that implements Countable in … on line 14 int[1]06
int[3] Warning: count[]: Parameter must be an array or an object that implements Countable in … on line 12 int[0] Warning: count[]: Parameter must be an array or an object that implements Countable in … on line 14 int[1]07
$time
2