Функция счетчика php должна быть массивом или объектом, который реализует Countable

У меня есть массив, показанный ниже, и эта строка в моем контроллере php:

 if(count($crew_rows != 0)){

Bluehost обновлен до php7.2, и теперь я получаю следующую ошибку:

Warning: count(): Parameter must be an array or an object that implements Countable in /home2/sailwbob/public_html/skipper/public/crew.php on line 1885

Как это исправить? (без возврата к более ранней версии php)

    Array
(
    [0] => Array
        (
            [0] => Array
                (
                    [date] => 2019-09-17
                    [usr] => 1
                    [skipUsr] => 1
                    [user] => 
                    [crew] => IN
                    [status] => OPEN
                    [avalstart] => 09:00:00
                    [avalend] => 21:00:00
                    [sort] => 0
                    [ssort] => 0
                )

            [1] => Array
                (
                    [date] => 2019-09-17
                    [usr] => 32
                    [skipUsr] => 1
                    [user] => 
                    [crew] => IN
                    [status] => OPEN
                    [avalstart] => 10:00:00
                    [avalend] => 20:00:00
                    [sort] => 9
                    [ssort] => 1
                )

            [2] => Array
                (
                    [date] => 2019-09-17
                    [usr] => 76
                    [skipUsr] => 1
                    [user] => 
                    [crew] => IN
                    [status] => OPEN
                    [avalstart] => 09:00:00
                    [avalend] => 21:00:00
                    [sort] => 9
                    [ssort] => 1
                )

            [3] => Array
                (
                    [date] => 2019-09-17
                    [usr] => 152
                    [skipUsr] => 1
                    [user] => 
                    [crew] => IN
                    [status] => OPEN
                    [avalstart] => 09:00:00
                    [avalend] => 21:00:00
                    [sort] => 9
                    [ssort] => 1
                )

            [4] => Array
                (
                    [date] => 2019-09-17
                    [usr] => 155
                    [skipUsr] => 1
                    [user] => 
                    [crew] => IN
                    [status] => OPEN
                    [avalstart] => 11:30:00
                    [avalend] => 21:00:00
                    [sort] => 9
                    [ssort] => 1
                )

            [5] => Array
                (
                    [date] => 2019-09-17
                    [usr] => 74
                    [skipUsr] => 1
                    [user] => 
                    [crew] => IN
                    [status] => OPEN
                    [avalstart] => 10:00:00
                    [avalend] => 18:00:00
                    [sort] => 9
                    [ssort] => 9
                )

            [6] => Array
                (
                    [date] => 2019-09-17
                    [usr] => 25
                    [skipUsr] => 1
                    [user] => 
                    [crew] => OUT
                    [status] => OUT
                    [avalstart] => 00:00:00
                    [avalend] => 00:00:00
                    [sort] => 9
                    [ssort] => 9
                )

            [7] => Array
                (
                    [date] => 2019-09-17
                    [usr] => 35
                    [skipUsr] => 1
                    [user] => 
                    [crew] => OUT
                    [status] => OUT
                    [avalstart] => 00:00:00
                    [avalend] => 00:00:00
                    [sort] => 9
                    [ssort] => 9
                )

            [8] => Array
                (
                    [date] => 2019-09-17
                    [usr] => 59
                    [skipUsr] => 1
                    [user] => 
                    [crew] => OUT
                    [status] => OUT
                    [avalstart] => 00:00:00
                    [avalend] => 00:00:00
                    [sort] => 9
                    [ssort] => 9
                )

            [9] => Array
                (
                    [date] => 2019-09-17
                    [usr] => 69
                    [skipUsr] => 1
                    [user] => 
                    [crew] => OUT
                    [status] => OUT
                    [avalstart] => 00:00:00
                    [avalend] => 00:00:00
                    [sort] => 9
                    [ssort] => 9
                )

            [10] => Array
                (
                    [date] => 2019-09-17
                    [usr] => 126
                    [skipUsr] => 1
                    [user] => 
                    [crew] => OUT
                    [status] => OUT
                    [avalstart] => 00:00:00
                    [avalend] => 00:00:00
                    [sort] => 9
                    [ssort] => 9
                )

            [11] => Array
                (
                    [date] => 2019-09-17
                    [usr] => 133
                    [skipUsr] => 1
                    [user] => 
                    [crew] => OUT
                    [status] => OUT
                    [avalstart] => 00:00:00
                    [avalend] => 00:00:00
                    [sort] => 9
                    [ssort] => 9
                )

            [12] => Array
                (
                    [date] => 2019-09-17
                    [usr] => 153
                    [skipUsr] => 1
                    [user] => 
                    [crew] => OUT
                    [status] => OUT
                    [avalstart] => 00:00:00
                    [avalend] => 00:00:00
                    [sort] => 9
                    [ssort] => 9
                )

            [13] => Array
                (
                    [date] => 2019-09-17
                    [usr] => 161
                    [skipUsr] => 1
                    [user] => 
                    [crew] => OUT
                    [status] => OUT
                    [avalstart] => 00:00:00
                    [avalend] => 00:00:00
                    [sort] => 9
                    [ssort] => 9
                )

        )

)

1 ответ

Решение

Закрывающая скобка стоит не в том месте в вашем ifзаявление. Должно получиться так:

if (count($crew_rows) != 0) {

Прямо сейчас вы передаете результат $crew_rows != 0 к count() функция - логическое значение, а не массив.

Другие вопросы по тегам