如何从多个数组中获取值

时间:2018-04-04 01:57:14

标签: php arrays

下面是显示来自某个客户的门票的数组。我试图从中获取一些价值,我想从ticket_id获得门票总数加上我想得到所有

的总时间总数
Array
(
  [0] => Array
    (
        [ticket_id] => 7098246
        [ticket_date_time] => 2/20/2018 17:22:35
            (
                [0] => Array
                    (
                        [call_type] => No Call
                        [caller_type] => Other
                        [start_time] => 4/3/2018 10:29:06
                        [end_time] => 4/3/2018 10:30:06
                        [total_time] => 00:01:00
                    )

                [1] => Array
                    (
                        [call_type] => No Call
                        [caller_type] => Other
                        [start_time] => 4/3/2018 10:30:06
                        [end_time] => 4/3/2018 10:42:03
                        [total_time] => 00:11:57
                    )

            )

    )

[1] => Array
    (
        [ticket_id] => 7139607
        [ticket_date_time] => 3/10/2018 21:50:05
            (
                [0] => Array
                    (
                        [call_type] => Other
                        [caller_type] => Other
                        [start_time] => 4/3/2018 17:24:34
                        [end_time] => 4/3/2018 17:28:05
                        [total_time] => 00:03:31
                    )

            )

    )

[2] => Array
    (
        [ticket_id] => 7192893
        [ticket_date_time] => 4/3/2018 0:37:06
            (
                [0] => Array
                    (
                        [call_type] => Inbound
                        [caller_type] => Guest
                        [start_time] => 4/3/2018 0:37:06
                        [end_time] => 4/3/2018 0:39:21
                        [total_time] => 00:02:15
                    )

            )

    )

[3] => Array
    (
        [ticket_id] => 7195274
        [ticket_date_time] => 4/3/2018 19:58:20
            (
                [0] => Array
                    (
                        [call_type] => Inbound
                        [caller_type] => Guest
                        [start_time] => 4/3/2018 19:58:20
                        [end_time] => 4/3/2018 20:27:23
                        [total_time] => 00:29:03
                    )

            )

    )

[4] => Array
    (
        [ticket_id] => 7195309
        [ticket_date_time] => 4/3/2018 20:06:44
            (
                [0] => Array
                    (
                        [call_type] => Inbound
                        [caller_type] => Guest
                        [start_time] => 4/3/2018 20:06:44
                        [end_time] => 4/3/2018 20:24:23
                        [total_time] => 00:17:39
                    )

            )

    )

1 个答案:

答案 0 :(得分:0)

抱歉无法测试这里是我最好的选择:D

$totalTicket = count($arrayName);

$total_time = 0;

foreach ($arrayName as $array) { 

foreach ($array as $ticket)
{
    $total_time = $ticket['total_time'] + $total_time;
}

}