Catch array_multisort warning

materix
Generous Backer | 47
+
0
-

Sometimes I find the warning “Array sizes are inconsistent” in the logs, for the command “array_multisort()”.

This is my code:

            $columns_1 = array_column($data, 'col1');
            $columns_2 = array_column($data, 'col2');
            $columns_3 = array_column($data, 'col3');
            array_multisort($columns_1, SORT_ASC, $columns_2, SORT_ASC, $columns_3, SORT_ASC, $data);

The $data is fetched from an remote api.

I expect the reason for the error, is that the remote data sometimes is corrupted.

Is there any method to “catch” when there is a warning in array_multisort?

nightfish
Member | 284
+
+1
-

@materix Not relevant to Nette, thus out-of-scope for this forum. This question is better suited for StackOverflow.

However – you can always check for yourself if all the arrays are of the same size and if not, not execute array_multisort.

materix
Generous Backer | 47
+
0
-

Thank you for the reply, and I apologize for posting in the wrong forum.

The sub-title for the “Miscellaneous”-forum is “talk about anything other than Nette”, so I expected it was the correct forum.