You're checking if $post_options['categoryid']['wpcatid'][1]
is not an array, but the preceding key 'wpcatid' also doesn't exist.
So you need to combine with isset
to avoid errors.
Below is an example, but the logic that you need may require a different statement:
if (isset(
$post_options['categoryid'],
$post_options['categoryid']['wpcatid'],
$post_options['categoryid']['wpcatid'][1]
) &&
!is_array($post_options['categoryid']['wpcatid'][1])
) { /* do stuff */ }
The above checks that everything exists in sequence before checking if $post_options['categoryid']['wpcatid'][1]
is not an array. If, however, it's just not set, but you still need to run your conditional logic, you'll need to amend that as applicable.
If you're writing a Wordpress plugin you can't change the error reporting level, and you definitely shouldn't resort to the error silence @
operator.
It's better you lay out explicitly under which conditions to you want to execute that particular part of your logic.
From the comments, it sounds like what you need is this:
if (
empty($post_options['categoryid']) ||
empty($post_options['categoryid']['wpcatid']) ||
empty($post_options['categoryid']['wpcatid'][1]) ||
!is_array($post_options['categoryid']['wpcatid'][1])
)
In plain English:
If (there's no category id in post options... or there is, but there's no wpcatid, or there's a wpcatid, but there's no element with a key of 1 in there, or there is, but that element is not an array)