gambitph / Titan-Framework

The easiest to use WordPress option framework.
http://www.titanframework.net
377 stars 137 forks source link

UNDEFINED OFFSET MESSAGE WHEN USING USER CREATED ARRAY AT RUN TIME #371

Open rogerad opened 8 years ago

rogerad commented 8 years ago

SEE PREVOUS POST

I CAN ADD THE ITEMS INTO THE ARRAY CORRECTLY NOW BUT WHEN THERE ARE MORE THAN 10 ITEMS , THE 10 TH ITEM AND LATER IS AN UNDEFINED OFFSET MESSAGE EG ERROR MESSAGE ON THESE LINES

'10' => $option_wp_roles_string[10], '11' => $option_wp_roles_string[11], '12' => $option_wp_roles_string[12], '13' => $option_wp_roles_string[13],

THE MESSAGE DOES NOT APPEAR ON ALL MY COMPUTERS ONLY ON 1 OF THEM

Notice: Undefined offset: 12 in C:\xampp\apps\wordpress\htdocs\wp-content\plugins\40mtest\40mtest.php on line 288

THESE LINES BELOW ARE PERFECT $aa_panel->createOption( array( 'name' => 'User Role Access', 'id' => 'aa_general_role', 'type' => 'multicheck', 'desc' => 'Which User Roles have Access to website - Administrators always have access', 'options' => array( // '1' => $option_wp_roles_string[0], '1' => $option_wp_roles_string[1], '2' => $option_wp_roles_string[2],

brandbrilliance commented 7 years ago

undefined offset is generated when you try to access an array with an invalid index, so the problem is that the array "$option_wp_roles_string" doesn't actually have 10-13 items. Perhaps you can generate the options automagically using a function above and then simply include them like so:] 'options' => $my_generated_options,