I have an array shown below and this line in my php controller:
if(count($crew_rows != 0)){
Bluehost upgraded to php7.2 and I now get the following error:
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
How do I fix this? (without reverting to an earlier version of 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
)
)
)
You have the closing parenthesis in the wrong place in your if
statement. It should look like this:
if (count($crew_rows) != 0) {
Right now, you're passing the result of $crew_rows != 0
to the count()
function - a boolean, rather than an array.