Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

WP_DEBUG is telling me:

Notice: Undefined index: no_cat_base in myplugin.php on line 20

Here's the lines of code where I'm pulling the value of "no_cat_base" from my options array called "myoptions"...

$myoptions = get_option('my_settings');

if($myoptions['no_cat_base']){//This is line 20}

Is the correct fix for this...

if ( isset($myoptions['no_cat_base'])){//do something}
share|improve this question
Not 100% sure, but if you're expecting an array from your setting (i.e. you're pulling action_plugins setting from the database), I believe you have to cast it as an array? –  Zack Feb 6 '11 at 4:50
Yes, its a multidimensional array. –  Scott B Feb 7 '11 at 4:02

1 Answer 1

up vote 1 down vote accepted

just to be on the safe side use:

if (array_key_exists('no_cat_base', $myoptions) && isset($myoptions['no_cat_base'])){
//do your thing
share|improve this answer
isset is enough, no need for array_key_exists –  onetrickpony Feb 6 '11 at 10:38
As i posted "just to be on the safe side", but yes isset is enough –  Bainternet Feb 6 '11 at 10:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.