Title: Warning: array_keys() [function.array-keys]:
Last modified: August 19, 2016

---

# Warning: array_keys() [function.array-keys]:

 *  Resolved [thedailymatters](https://wordpress.org/support/users/thedailymatters/)
 * (@thedailymatters)
 * [18 years ago](https://wordpress.org/support/topic/warning-array_keys-functionarray-keys/)
 * Warning: array_keys() [function.array-keys]: The first argument should be an 
   array in /home/ymaindomain/public_html/mydomain/wp-includes/widgets.php on line
   676
 * Warning: Invalid argument supplied for foreach() in /home/mymaindomain/public_html/
   mydomain/wp-includes/widgets.php on line 676
 * **What could this error mean? I got this after adding some code to my widget 
   Please help. ASAP**

Viewing 15 replies - 16 through 30 (of 41 total)

[←](https://wordpress.org/support/topic/warning-array_keys-functionarray-keys/?output_format=md&replies=26)
[1](https://wordpress.org/support/topic/warning-array_keys-functionarray-keys/?output_format=md&replies=26)
2 [3](https://wordpress.org/support/topic/warning-array_keys-functionarray-keys/page/3/?output_format=md&replies=26)
[→](https://wordpress.org/support/topic/warning-array_keys-functionarray-keys/page/3/?output_format=md&replies=26)

 *  [cheetah1](https://wordpress.org/support/users/cheetah1/)
 * (@cheetah1)
 * [17 years, 9 months ago](https://wordpress.org/support/topic/warning-array_keys-functionarray-keys/page/2/#post-751853)
 * Oh well, I got about the same errors as the OP, and another one. Can someone 
   simply tell me what’s wrong?
 *     ```
       Warning: array_keys() [function.array-keys]: The first argument should be an array in /var/www/arkiv.cristianswebsite.org/wp-includes/widgets.php on line 1352
   
       Warning: Invalid argument supplied for foreach() in /var/www/arkiv.cristianswebsite.org/wp-includes/widgets.php on line 1352
   
       Warning: Cannot modify header information - headers already sent by (output started at /var/www/arkiv.cristianswebsite.org/wp-includes/widgets.php:1352) in /var/www/arkiv.cristianswebsite.org/wp-includes/pluggable.php on line 770
       ```
   
 *  783462
 * [17 years, 9 months ago](https://wordpress.org/support/topic/warning-array_keys-functionarray-keys/page/2/#post-751855)
 * Same for me here.
 *  [dorfun](https://wordpress.org/support/users/dorfun/)
 * (@dorfun)
 * [17 years, 9 months ago](https://wordpress.org/support/topic/warning-array_keys-functionarray-keys/page/2/#post-751856)
 * If you have this error:
 * `Warning: array_keys() [function.array-keys]: The first argument should be an
   array in [...] on line 1352`
 * Try to deactivate all widgets (and no only plugins). Use a widget-ready theme,
   deactive all them… and maybe will be ok! 🙂
 * It works for me.
 *  [totof2k2](https://wordpress.org/support/users/totof2k2/)
 * (@totof2k2)
 * [17 years, 9 months ago](https://wordpress.org/support/topic/warning-array_keys-functionarray-keys/page/2/#post-751857)
 * Hello Dorfun
 * Can you tell me, how you can desactivate all widgets ? i can’t acces to my admin
   panel…
    all Plugins are OFF,
 * thanks for your help
 * christophe
 *  [Wiki Chaves](https://wordpress.org/support/users/wikichaves/)
 * (@wikichaves)
 * [17 years, 9 months ago](https://wordpress.org/support/topic/warning-array_keys-functionarray-keys/page/2/#post-751860)
 * Hi !
 * i have the same problem ? how can i desactivate the widgets . i can´t access 
   to my admin panel
 * take a look
 * [http://wikichaves.com/blog/](http://wikichaves.com/blog/)
    [http://wikichaves.com/blog/wp-admin/](http://wikichaves.com/blog/wp-admin/)
 * thanks !
    francisco
 *  [cheetah1](https://wordpress.org/support/users/cheetah1/)
 * (@cheetah1)
 * [17 years, 9 months ago](https://wordpress.org/support/topic/warning-array_keys-functionarray-keys/page/2/#post-751863)
 * Well, I have to ask the same. How do you do that when you can’t access the gui?
 *  [@mercime](https://wordpress.org/support/users/mercime/)
 * (@mercime)
 * [17 years, 9 months ago](https://wordpress.org/support/topic/warning-array_keys-functionarray-keys/page/2/#post-751864)
 * The fastest way to de-activate widgets when you cannot access your WP admin is
   by deleting the plugin from FTP.
 *  [davosian](https://wordpress.org/support/users/davosian/)
 * (@davosian)
 * [17 years, 8 months ago](https://wordpress.org/support/topic/warning-array_keys-functionarray-keys/page/2/#post-751869)
 * Here is how I fixed it:
 * To gain access to your widget page, simply comment out two lines of your wp-config.
   php file:
 *     ```
       // define('DB_CHARSET', 'utf8');
       // define('DB_COLLATE', '');
       ```
   
 * Then log in and go to your widget page.
    Remove each text widget and PHP widget(
   copy the content into a text editor so you can retrieve it afterwards again).
   Go back into your wp-config.php file and remove the comments again. Save. Log
   in and add your text widgets again. This should work fine now.
 *  [beritany](https://wordpress.org/support/users/beritany/)
 * (@beritany)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/warning-array_keys-functionarray-keys/page/2/#post-751880)
 * here’s what comes to my blog after i tried to log-in
 * Warning: array_keys() [function.array-keys]: The first argument should be an 
   array in /home/beritany/public_html/wp-includes/widgets.php on line 686
 * Warning: Invalid argument supplied for foreach() in /home/beritany/public_html/
   wp-includes/widgets.php on line 686
 * Warning: Cannot modify header information – headers already sent by (output started
   at /home/beritany/public_html/wp-includes/widgets.php:686) in /home/beritany/
   public_html/wp-login.php on line 267
 * Warning: Cannot modify header information – headers already sent by (output started
   at /home/beritany/public_html/wp-includes/widgets.php:686) in /home/beritany/
   public_html/wp-login.php on line 279
 * Warning: Cannot modify header information – headers already sent by (output started
   at /home/beritany/public_html/wp-includes/widgets.php:686) in /home/beritany/
   public_html/wp-includes/pluggable.php on line 595
 * Warning: Cannot modify header information – headers already sent by (output started
   at /home/beritany/public_html/wp-includes/widgets.php:686) in /home/beritany/
   public_html/wp-includes/pluggable.php on line 596
 * Warning: Cannot modify header information – headers already sent by (output started
   at /home/beritany/public_html/wp-includes/widgets.php:686) in /home/beritany/
   public_html/wp-includes/pluggable.php on line 597
 * Warning: Cannot modify header information – headers already sent by (output started
   at /home/beritany/public_html/wp-includes/widgets.php:686) in /home/beritany/
   public_html/wp-includes/pluggable.php on line 770
 * can anyone help me? i cant log in, i cant remove my widgets, and i dont even 
   know what mistakes that i made….
 *  [philsouthwark](https://wordpress.org/support/users/philsouthwark/)
 * (@philsouthwark)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/warning-array_keys-functionarray-keys/page/2/#post-751882)
 * Same here – I added a text widget and immediately was inundated with the same
   error as above.
 * But all the widgets disappeared at the same time so there are none to delete.
 * I have tried commenting out the lines suggested. I have also tried replacing 
   the widget.php files with originals – so far nothign has got rid of these errors–
   any ideas please? I have searched on this and there doesn’t seem to be much help
   online.
 *  [Laura McDonald](https://wordpress.org/support/users/laura1234/)
 * (@laura1234)
 * [17 years, 6 months ago](https://wordpress.org/support/topic/warning-array_keys-functionarray-keys/page/2/#post-751883)
 * hey guys, i was having this problem with a site that i migrated to a local server
   for development. the way i solved it was:
    – open wp-includes/widgets.php – go
   to line 686 and cut out this part (only temporarily, make sure you can put it
   back later!) — foreach ( array_keys($options) as $o ) { // Old widgets can have
   null values for some reason if ( !isset($options[$o][‘title’]) || !isset($options[
   $o][‘text’]) ) continue; $id = “text-$o”; // Never never never translate an id
   wp_register_sidebar_widget($id, $name, ‘wp_widget_text’, $widget_ops, array( ‘
   number’ => $o )); wp_register_widget_control($id, $name, ‘wp_widget_text_control’,
   $control_ops, array( ‘number’ => $o )); } — you will then be able to log into
   your site. per some people’s previous instructions, i then messed around a little
   with my widgets, re-saved them, and then deactivated then reactivated my plugins.
   then i put the above code back and the site works.
 * i’m not exactly sure how, but it solved the problem for me.
 *  [DomainClaimers](https://wordpress.org/support/users/domainclaimers/)
 * (@domainclaimers)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/warning-array_keys-functionarray-keys/page/2/#post-751889)
 * I can’t log on to the wordpress site to edit anything, I can get into my FTP 
   account but have no idea how to delete these lines
 * > // define(‘DB_CHARSET’, ‘utf8’);
   >  // define(‘DB_COLLATE’, ”);
 * That file won’t let me edit anything, I have had problems with code before but
   never anything that wouldn’t let me log onto the wp site to edit code there. 
   I know why I hate to update WordPress, I have no idea what to try next, if this
   is just a text widget problem I could fix it easily if I had access to the admin
   panel.
 * Still need help if anyone can help……
 *  [dukeofdordogne](https://wordpress.org/support/users/dukeofdordogne/)
 * (@dukeofdordogne)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/warning-array_keys-functionarray-keys/page/2/#post-751890)
 * I had the exact same problem / error, although mine was with a fresh install.
   
   All I did was clear my cached files and history, refreshed and the error has 
   gone..
 * Hope this helps others..
 * The Duke
 *  [DomainClaimers](https://wordpress.org/support/users/domainclaimers/)
 * (@domainclaimers)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/warning-array_keys-functionarray-keys/page/2/#post-751891)
 * > // define(‘DB_CHARSET’, ‘utf8’);
   >  // define(‘DB_COLLATE’, ”);
 * I put a **/\*** before and after the above code each line, this allowed the site
   to come back and I was able to log onto it, now do I still need this code and
   what is it for?
 * What does the above two lines of code do anyway?
 *  [DomainClaimers](https://wordpress.org/support/users/domainclaimers/)
 * (@domainclaimers)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/warning-array_keys-functionarray-keys/page/2/#post-751892)
 * **Update – ** after doing the above it did allow me to work on my website but
   I found no text widgets in the sidebar, it also shut down 5 other websites on
   the same server as mine since those are also my websites it was obvious that 
   taking that code out is not going to fix the problem. Not sure what to try next,
   maybe going back in and taking the text code out of the header and deleting all
   comments this would leave no text errors possible, maybe upgraded or deactivate
   all the plug ins.

Viewing 15 replies - 16 through 30 (of 41 total)

[←](https://wordpress.org/support/topic/warning-array_keys-functionarray-keys/?output_format=md&replies=26)
[1](https://wordpress.org/support/topic/warning-array_keys-functionarray-keys/?output_format=md&replies=26)
2 [3](https://wordpress.org/support/topic/warning-array_keys-functionarray-keys/page/3/?output_format=md&replies=26)
[→](https://wordpress.org/support/topic/warning-array_keys-functionarray-keys/page/3/?output_format=md&replies=26)

The topic ‘Warning: array_keys() [function.array-keys]:’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 41 replies
 * 36 participants
 * Last reply from: [ldelre](https://wordpress.org/support/users/ldelre/)
 * Last activity: [17 years, 2 months ago](https://wordpress.org/support/topic/warning-array_keys-functionarray-keys/page/3/#post-751915)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
