WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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.