If you encounter the “Trying to access array offset on value of type int” error while attempting to access a PHP array index, the issue may be that the specified index does not exist in the array.
echo $your_array['key'];
And most likely the array is not null and but the index you are trying to access does not exists.
To avoid this error, verify that the array has the desired index before attempting to access it. One way to accomplish this is by using the following code:
echo isset($your_array['key']) && $your_array['key'];
Alternatively, you can use a ternary operator to check if the index exists and output its value or 0 if it does not:
echo isset($your_array['key']) ? $your_array['key'] : 0;