PHP Array

How to fix the PHP "Illegal offset type" error

Submitted by oretnom23 on
How to fix the PHP "Illegal offset type" error

If you are currently facing a "Fatal error: Uncaught TypeError: Illegal offset type in ..." error in your PHP code or script, this article can help you to solve this kind of PHP error.

PHP's Illegal offset Type error occurs when you are trying to use a full object or array as the key of an array. PHP array keys can only be a string or integer type.

Example #1

Let's assume that we the following PHP code: